aboutsummaryrefslogtreecommitdiff
path: root/internal/crypto_utilities.py
blob: adc8506b9b5a07daad12539bf29644485147ddc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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()