Chapter 9. Cryptography

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

9.1 hashlib: Cryptographic Hashing

The hashlib module defines an API for accessing different cryptographic hashing algorithms. To work with a specific hash algorithm, use the appropriate constructor function or new() to create a hash object. From there, the objects use the same API, no matter which algorithm is being used.

9.1.1 Hash Algorithms

Since hashlib is “backed” by OpenSSL, all ...

Get The Python 3 Standard Library by Example, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.