aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'util.py')
-rw-r--r--util.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/util.py b/util.py
new file mode 100644
index 0000000..61efa0b
--- /dev/null
+++ b/util.py
@@ -0,0 +1,18 @@
1from cryptography.fernet import Fernet
2
3
4def encrypt(input: str, key: str) -> str:
5 f = Fernet(key)
6 return f.encrypt(bytes(input, 'utf-8')).decode('utf-8')
7
8
9def decrypt(input: str, key: str) -> str:
10 f = Fernet(key)
11 return f.decrypt(input).decode('utf-8')
12
13
14# if __name__ == "__main__":
15# key = Fernet.generate_key().decode('utf-8')
16# print(key)
17# print(encrypt("Hello World!", key))
18# print(decrypt(encrypt("Hello World!", key), key))
Powered by cgit v1.2.3 (git 2.41.0)