Skip to content

Instantly share code, notes, and snippets.

@HamdyTawfeek
Created April 26, 2020 05:39
Show Gist options
  • Select an option

  • Save HamdyTawfeek/b76d6919484645dffe077adfb1a7bbe5 to your computer and use it in GitHub Desktop.

Select an option

Save HamdyTawfeek/b76d6919484645dffe077adfb1a7bbe5 to your computer and use it in GitHub Desktop.
# Import Package
from cryptography.fernet import Fernet
# Generate a Key and Instantiate a Fernet Instance
key = Fernet.generate_key()
f = Fernet(key)
print(key)
# Define our message
plaintext = b"encryption is very useful"
# Encrypt
ciphertext = f.encrypt(plaintext)
print(ciphertext)
# Decrypt
decryptedtext = f.decrypt(ciphertext)
print(decryptedtext)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment