aboutsummaryrefslogtreecommitdiff
path: root/yoshi/crypto.py
diff options
context:
space:
mode:
Diffstat (limited to 'yoshi/crypto.py')
-rw-r--r--yoshi/crypto.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/yoshi/crypto.py b/yoshi/crypto.py
index 9b0a423..d85fbe9 100644
--- a/yoshi/crypto.py
+++ b/yoshi/crypto.py
@@ -6,7 +6,7 @@ It allows for secure encryption and decryption of data using a secret key.
from cryptography.fernet import Fernet
-VAULT_FILE = 'vault.sqlite'
+VAULT_FILE = "vault.sqlite"
def generate_key() -> bytes:
@@ -21,25 +21,25 @@ def load_key(key_file: str) -> bytes:
Args:
key_file (str): Path to the key file.
"""
- with open(key_file, 'rb') as key:
+ 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:
+ with open(filename, "rb") as vault:
data = vault.read()
encrypted_data = f.encrypt(data)
- with open(filename, 'wb') as vault:
+ 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:
+ with open(filename, "rb") as vault:
encrypted_data = vault.read()
decrypted_data = f.decrypt(encrypted_data)
- with open(filename, 'wb') as vault:
+ with open(filename, "wb") as vault:
vault.write(decrypted_data)