aboutsummaryrefslogblamecommitdiff
blob: 61efa0b491a7efb0da4b774236996b99dd5c1cba (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

















                                                           
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))
Powered by cgit v1.2.3 (git 2.41.0)