aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2023-02-23 15:38:38 -0800
committerclarkzjw <[email protected]>2023-02-23 15:38:38 -0800
commit20b8220a12fc92f95ecae267ce4eb5a80584f564 (patch)
tree1090256b48a76aae7afe2e10b860a02b43790807 /util.py
parent31a2d111d1c0ceb2ebfd5bb5daf4ee0ab2de4eb4 (diff)
parent4cee8500a51aff6d0a445a3a6259cafed92d4845 (diff)
downloadswarm2fediverse-20b8220a12fc92f95ecae267ce4eb5a80584f564.tar.gz
Merge branch 'feature/encryption'
- bot: encrypt access_key with cryptography.fernet library
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)