aboutsummaryrefslogtreecommitdiff
path: root/internal/crypto_utilities.py
diff options
context:
space:
mode:
authorBobby <[email protected]>2025-03-11 01:14:10 +0530
committerBobby <[email protected]>2025-03-11 01:14:10 +0530
commit9085fa19a9972f0c31f0ba92505c77a52acf3d66 (patch)
treeb7f4f57e95fb0467014d20a8ce227a062c500a8f /internal/crypto_utilities.py
parentf5ef9d42ebe7b2be932b35db7c5d801e9cfeb2c1 (diff)
downloadthatcomputerscientist-dev.tar.xz
thatcomputerscientist-dev.zip
separate video/tracks in anime stream service and encodedev
Diffstat (limited to 'internal/crypto_utilities.py')
-rw-r--r--internal/crypto_utilities.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/internal/crypto_utilities.py b/internal/crypto_utilities.py
new file mode 100644
index 00000000..adc8506b
--- /dev/null
+++ b/internal/crypto_utilities.py
@@ -0,0 +1,16 @@
+import os
+from cryptography.fernet import Fernet
+import base64
+
+AUTHORIZATION_STRING = os.getenv("AUTHORIZATION_STRING")
+SECRET_KEY = base64.urlsafe_b64encode(AUTHORIZATION_STRING[:32].encode())
+
+cipher = Fernet(SECRET_KEY)
+
+
+def encode_url(url):
+ return cipher.encrypt(url.encode()).decode()
+
+
+def decode_url(encrypted_url):
+ return cipher.decrypt(encrypted_url.encode()).decode()