import os import streamlit as st from cryptography.fernet import Fernet from dotenv import load_dotenv # Load environment variables from .env file load_dotenv() # Get the ENC_DEC_KEY from the .env file ENC_DEC_KEY = os.getenv("ENC_DEC_KEY").encode() # Ensure this is a bytes object @st.cache_data() def decrypt_file(file_path): fernet = Fernet(ENC_DEC_KEY) with open(file_path, "rb") as file: encrypted_data = file.read() decrypted_data = fernet.decrypt(encrypted_data) return decrypted_data.decode() # Return the decrypted content as a string