cryptography is a package which provides cryptographic recipes and
primitives to Python developers. Our goal is for it to be your “cryptographic
standard library”. It supports Python 2.6-2.7, Python 3.3+, and PyPy.
cryptography includes both high level recipes, and low level interfaces to
common cryptographic algorithms such as symmetric ciphers, message digests and
key derivation functions. For example, to encrypt something with
cryptography’s high level symmetric encryption recipe:
>>> fromcryptography.fernetimportFernet>>> # Put this somewhere safe!>>> key=Fernet.generate_key()>>> f=Fernet(key)>>> token=f.encrypt(b"A really secret message. Not for prying eyes.")>>> token'...'
>>> f.decrypt(token)'A really secret message. Not for prying eyes.'