first commit
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
# app/middlewares/encryption.py
|
||||
from cryptography.fernet import Fernet
|
||||
import os
|
||||
|
||||
ENCRYPTION_KEY = os.getenv("ENCRYPTION_KEY", Fernet.generate_key())
|
||||
cipher = Fernet(ENCRYPTION_KEY)
|
||||
|
||||
def encrypt_data(data):
|
||||
"""Encrypt sensitive data"""
|
||||
return cipher.encrypt(data.encode()).decode()
|
||||
|
||||
def decrypt_data(data):
|
||||
"""Decrypt sensitive data"""
|
||||
return cipher.decrypt(data.encode()).decode()
|
||||
Reference in New Issue
Block a user