Spaces:
Build error
Build error
Download crypto_utils.py from tayyardurden/mstts: direct link, hf CLI and curl.
- Browser
- Download file 593 Bytes
-
https://huggingface.co/spaces/tayyardurden/mstts/resolve/main/crypto_utils.py
- Command line
-
hf download hf://spaces/tayyardurden/mstts/crypto_utils.py
-
curl -L -o crypto_utils.py https://huggingface.co/spaces/tayyardurden/mstts/resolve/main/crypto_utils.py
593 Bytes
| 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 | |
| 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 |