diff options
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/crypto_utilities.py | 16 |
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() |
