O'Reilly logo

The Python Standard Library by Example by Doug Hellmann

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 9. Cryptography

Encryption secures messages so that they can be verified as accurate and protected from interception. Python’s cryptography support includes hashlib for generating signatures of message content using standard algorithms, such as MD5 and SHA, and hmac for verifying that a message has not been altered in transmission.

9.1 hashlib—Cryptographic Hashing

Purpose Generate cryptographic hashes and message digests.

Python Version 2.5 and later

The hashlib module deprecates the separate md5 and sha modules and makes their API consistent. To work with a specific hash algorithm, use the appropriate constructor function to create a hash object. From there, the objects use the same API, no matter what algorithm is being used.

Since ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required