Skip to content

Commit 6c5c191

Browse files
Potential fix for code scanning alert no. 513: Use of a broken or weak cryptographic hashing algorithm on sensitive data (#2401)
Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 0a6be93 commit 6c5c191

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

CogniwareIms/backend/app/core/security.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ def create_api_key() -> str:
114114
@staticmethod
115115
def hash_api_key(api_key: str) -> str:
116116
"""Hash an API key for storage."""
117-
return hashlib.sha256(api_key.encode()).hexdigest()
117+
return pwd_context.hash(api_key)
118118

119119
@staticmethod
120120
def verify_api_key(api_key: str, hashed_key: str) -> bool:
121121
"""Verify an API key against its hash."""
122-
return hashlib.sha256(api_key.encode()).hexdigest() == hashed_key
122+
return pwd_context.verify(api_key, hashed_key)
123123

124124

125125
def get_current_user(

0 commit comments

Comments
 (0)