init commit
This commit is contained in:
10
app/services/crypto.py
Normal file
10
app/services/crypto.py
Normal file
@@ -0,0 +1,10 @@
|
||||
import base64
|
||||
|
||||
def encrypt_token(token: str, secret: str) -> str:
|
||||
# TODO: заменить на реальное шифрование (Fernet) — здесь простая обёртка
|
||||
raw = f"{secret}:{token}".encode()
|
||||
return base64.urlsafe_b64encode(raw).decode()
|
||||
|
||||
def decrypt_token(token_enc: str, secret: str) -> str:
|
||||
data = base64.urlsafe_b64decode(token_enc.encode()).decode()
|
||||
return data.split(":", 1)[1]
|
||||
Reference in New Issue
Block a user