From c7e5d9fbec9418d856be961358e35f603bbbf523 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Wed, 6 Nov 2024 21:52:32 -0600 Subject: configure as pypi hosted app --- crypto.py | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 crypto.py (limited to 'crypto.py') diff --git a/crypto.py b/crypto.py deleted file mode 100644 index 9b0a423..0000000 --- a/crypto.py +++ /dev/null @@ -1,45 +0,0 @@ -""" -This module imports the Fernet symmetric encryption algorithm from the cryptography library. - -It allows for secure encryption and decryption of data using a secret key. -""" - -from cryptography.fernet import Fernet - -VAULT_FILE = 'vault.sqlite' - - -def generate_key() -> bytes: - """Generates a new encryption key.""" - return Fernet.generate_key() - - -def load_key(key_file: str) -> bytes: - """ - Loads an existing encryption key from the file. - - Args: - key_file (str): Path to the key file. - """ - with open(key_file, 'rb') as key: - return key.read() - - -def encrypt(key: bytes, filename: str = VAULT_FILE) -> None: - """Encrypts the data in the specified file using the provided key.""" - f = Fernet(key) - with open(filename, 'rb') as vault: - data = vault.read() - encrypted_data = f.encrypt(data) - with open(filename, 'wb') as vault: - vault.write(encrypted_data) - - -def decrypt(key: bytes, filename: str = VAULT_FILE) -> None: - """Decrypts the data in the specified file using the provided key.""" - f = Fernet(key) - with open(filename, 'rb') as vault: - encrypted_data = vault.read() - decrypted_data = f.decrypt(encrypted_data) - with open(filename, 'wb') as vault: - vault.write(decrypted_data) -- cgit v1.2.3-70-g09d2