aboutsummaryrefslogtreecommitdiff
path: root/yoshi/crypto.py
diff options
context:
space:
mode:
authorChristian Cleberg <hello@cleberg.net>2025-04-05 13:36:49 -0500
committerGitHub <noreply@github.com>2025-04-05 13:36:49 -0500
commitc8617ce8aecb40ccf1d13c02dcd7d7e74e79b56b (patch)
treecf901030197768b2aa21d2d3fcf0426948a94111 /yoshi/crypto.py
parent1fc982100a13de26bfca3419d1a6c5a65acad3d2 (diff)
downloadyoshi-cli-c8617ce8aecb40ccf1d13c02dcd7d7e74e79b56b.tar.gz
yoshi-cli-c8617ce8aecb40ccf1d13c02dcd7d7e74e79b56b.tar.bz2
yoshi-cli-c8617ce8aecb40ccf1d13c02dcd7d7e74e79b56b.zip
migrate from pylint to ruff-action (#4)
* migrate from pylint to ruff-action * temporarily disable push param * Commit from GitHub Actions (Pylint) * re-enable push param --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
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)