File size: 1,149 Bytes
11cc0d3
 
 
3844129
0c8b990
11cc0d3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
from cryptography.fernet import Fernet

KEY_FILE = "app/chroma_key.key"
CHROMA_PATH = "app/chroma_db"

def decrypt_chroma_files():
    # Load key
    with open(KEY_FILE, "rb") as f:
        key = f.read()
    fernet = Fernet(key)
    
    # Decrypt all .enc files
    for root, _, files in os.walk(CHROMA_PATH):
        for file in files:
            if not file.endswith(".enc"):
                continue
                
            encrypted_path = os.path.join(root, file)
            original_path = encrypted_path[:-4]  # Remove .enc
            
            try:
                with open(encrypted_path, "rb") as f:
                    encrypted_data = f.read()
                decrypted_data = fernet.decrypt(encrypted_data)
                with open(original_path, "wb") as f:
                    f.write(decrypted_data)
                os.remove(encrypted_path)
                print(f"Decrypted: {original_path}")
            except Exception as e:
                print(f"Error decrypting {encrypted_path}: {e}")

if __name__ == "__main__":
    decrypt_chroma_files()
    print("Decryption complete. ChromaDB ready for use.")