MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / _hash_password

Method _hash_password

auth_manager.py:192–202  ·  view source on GitHub ↗

Hash a password with PBKDF2-SHA256. Returns (hash_hex, salt_hex).

(password: str, salt: bytes = None)

Source from the content-addressed store, hash-verified

190
191 @staticmethod
192 def _hash_password(password: str, salt: bytes = None) -> tuple:
193 """Hash a password with PBKDF2-SHA256. Returns (hash_hex, salt_hex)."""
194 if salt is None:
195 salt = secrets.token_bytes(32)
196 pw_hash = hashlib.pbkdf2_hmac(
197 'sha256',
198 password.encode('utf-8'),
199 salt,
200 AuthManager.PBKDF2_ITERATIONS
201 )
202 return pw_hash.hex(), salt.hex()
203
204 @staticmethod
205 def _verify_password(password: str, stored_hash: str, stored_salt: str) -> bool:

Callers 4

setupMethod · 0.95
change_passwordMethod · 0.95
recoverMethod · 0.95

Calls 1

encodeMethod · 0.45

Tested by

no test coverage detected