Created
September 9, 2020 14:45
-
-
Save stanwu/5042834d5e20bfede3357be32e077740 to your computer and use it in GitHub Desktop.
Full Code Example (decode)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from cryptography.fernet import Fernet | |
| def load_key(): | |
| """ | |
| Load the previously generated key | |
| """ | |
| return open("secret.key", "rb").read() | |
| def decrypt_message(encrypted_message): | |
| """ | |
| Decrypts an encrypted message | |
| """ | |
| key = load_key() | |
| f = Fernet(key) | |
| decrypted_message = f.decrypt(encrypted_message) | |
| print(decrypted_message.decode()) | |
| if __name__ == "__main__": | |
| decrypt_message(b'gAAAAABesCUIAcM8M-_Ik_-I1-JD0AzLZU8A8-AJITYCp9Mc33JaHMnYmRedtwC8LLcYk9zpTqYSaDaqFUgfz-tcHZ2TQjAgKKnIWJ2ae9GDoea6tw8XeJ4=') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment