This commit is contained in:
2025-10-17 09:26:56 -04:00
parent 6b68ea19dd
commit 766657da8b
28 changed files with 5302 additions and 15 deletions
+16 -14
View File
@@ -32,6 +32,8 @@ SALT_SIZE = 16 # 128-bit Salt
NONCE_SIZE = 12 # AES-GCM
KEY_SIZE = 32 # AES-256
logger = logging.getLogger(__name__)
def _derive_key(password: bytes, salt: bytes) -> bytes:
kdf = PBKDF2HMAC(
@@ -66,6 +68,20 @@ def store_api_key(service: str, username: str, api_key: str, password: str):
b64 = base64.b64encode(blob).decode()
keyring.set_password(service, username, b64)
logger.debug(f"API key for service '{service}' and user '{username}' stored successfully.")
print("\n✅ API key stored securely.")
print("The program will now exit. Press Enter to continue...")
try:
_ = input()
except Exception:
pass
_ = None
sys.exit(0)
def retrieve_api_key(service: str, username: str, password: str) -> str:
configure_keyring_backend()
@@ -80,20 +96,6 @@ def retrieve_api_key(service: str, username: str, password: str) -> str:
aesgcm = AESGCM(key)
pt = aesgcm.decrypt(nonce, ct, associated_data=None)
return pt.decode()
logger.debug(f"API key for service '{service}' and user '{username}' stored successfully.")
print("\n✅ API key stored securely.")
print("The program will now exit. Press Enter to continue...")
try:
_ = input()
except Exception:
pass
_ = None
sys.exit(0)
def api_key_exists(service: str, username: str) -> bool: