blob: 61efa0b491a7efb0da4b774236996b99dd5c1cba (
plain) (
tree)
|
|
from cryptography.fernet import Fernet
def encrypt(input: str, key: str) -> str:
f = Fernet(key)
return f.encrypt(bytes(input, 'utf-8')).decode('utf-8')
def decrypt(input: str, key: str) -> str:
f = Fernet(key)
return f.decrypt(input).decode('utf-8')
# if __name__ == "__main__":
# key = Fernet.generate_key().decode('utf-8')
# print(key)
# print(encrypt("Hello World!", key))
# print(decrypt(encrypt("Hello World!", key), key))
|