cryptography python 1

cryptography python

>>> from cryptography.fernet import Fernet
>>> # 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.'

Here is what the above code is Doing:
1. Generate a key
2. Create a Fernet object with that key
3. Use the Fernet object to encrypt a message
4. Use the Fernet object to decrypt the encrypted message

Similar Posts