Code Room
Code reviewMedium
Question
Review this Python password storage.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
import hashlib, os def hash_password(password: str) -> str: salt = os.urandom(16) digest = hashlib.sha256(salt + password.encode()).hexdigest() return salt.hex() + ':' + digest def verify(password: str, stored: str) -> bool: salt_hex, digest = stored.split(':') salt = bytes.fromhex(salt_hex) return hashlib.sha256(salt + password.encode()).hexdigest() == digestRun or narrate your approach, then ask the coach.