Skip to content

Commit 8efc85b

Browse files
committed
feat: show API key SHA256 hash instead of asterisk masking
Replace the generic asterisk masking with a deterministic SHA256 hash prefix to allow developers to verify which API key is being used while maintaining security. Changes: - Add hashlib import for SHA256 support - Create get_api_key_hash() helper function - Update config display to show: API_KEY=sha256:<hash_prefix>...
1 parent 9cc2e8c commit 8efc85b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/core/config.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import sys
3+
import hashlib
34

45
# Configuration
56
class Config:
@@ -69,9 +70,15 @@ def get_custom_headers(self):
6970

7071
return custom_headers
7172

73+
def get_api_key_hash(api_key):
74+
"""Generate SHA256 hash of API key for secure display"""
75+
if not api_key:
76+
return "<not-set>"
77+
return hashlib.sha256(api_key.encode()).hexdigest()[:8]
78+
7279
try:
7380
config = Config()
74-
print(f" Configuration loaded: API_KEY={'*' * 20}..., BASE_URL='{config.openai_base_url}'")
81+
print(f" Configuration loaded: API_KEY=sha256:{get_api_key_hash(config.openai_api_key)}..., BASE_URL='{config.openai_base_url}'")
7582
except Exception as e:
7683
print(f"=4 Configuration Error: {e}")
7784
sys.exit(1)

0 commit comments

Comments
 (0)