tayyardurden/mstts
0
1import os
2import streamlit as st
3from cryptography.fernet import Fernet
4from dotenv import load_dotenv
5
6# Load environment variables from .env file
7load_dotenv()
8
9# Get the ENC_DEC_KEY from the .env file
10ENC_DEC_KEY = os.getenv("ENC_DEC_KEY").encode() # Ensure this is a bytes object
11
12@st.cache_data()
13def decrypt_file(file_path):
14 fernet = Fernet(ENC_DEC_KEY)
15
16 with open(file_path, "rb") as file:
17 encrypted_data = file.read()
18
19 decrypted_data = fernet.decrypt(encrypted_data)
20 return decrypted_data.decode() # Return the decrypted content as a string