aarthigoud's picture
Upload 5 files
903ee16 verified
raw
history blame contribute delete
347 Bytes
from cryptography.fernet import Fernet
import base64
def encrypt_pdf(pdf_bytes, key):
cipher = Fernet(base64.urlsafe_b64encode(key.ljust(32)[:32]))
return cipher.encrypt(pdf_bytes)
def decrypt_pdf(encrypted_bytes, key):
cipher = Fernet(base64.urlsafe_b64encode(key.ljust(32)[:32]))
return cipher.decrypt(encrypted_bytes)