symmetric lib

This commit is contained in:
Votre Nom 2019-11-08 17:45:41 +01:00
parent 36787a7e19
commit 429276cf94
3 changed files with 20 additions and 0 deletions

Binary file not shown.

1
utils/key.key Normal file
View File

@ -0,0 +1 @@
c8Vo7OdLcNQJL2aDeLVepcGwOkXxnibd_BiOL6r42TM=

View File

@ -0,0 +1,19 @@
# Symmetric crypto lib
from cryptography.fernet import Fernet
key = Fernet.generate_key()
file = open('key.key', 'wb')
file.write(key) # The key is type bytes still
file.close()
message = "my deep dark secret".encode()
f = Fernet(key)
encrypted = f.encrypt(message)
print(encrypted)
decrypted = f.decrypt(encrypted)
print(decrypted)