Hash one password under three different salts and watch the stored digests diverge — then hash it with no salt and watch two users store byte-identical records. Digests are truncated to 16 hex characters so the output stays readable.
Hash one password under three different salts and watch the stored digests diverge — then hash it with no salt and watch two users store byte-identical records. Digests are truncated to 16 hex characters so the output stays readable.
Answer
import hashlib def stored(password, salt): return hashlib.pbkdf2_hmac('sha256', password.encode(), salt, 100_000).hex()[:16] pw = 'autumn-lantern' for salt in (b'salt:alice', b'salt:bob', b'salt:carol'): print(salt.decode(), '->', stored(pw, salt)) bare = hashlib.sha256(pw.encode()).hexdigest()[:16] print('unsalted alice ->', bare) print('unsalted bob ->', bare) print('same password, same unsalted hash:', bare == hashlib.sha256(pw.encode()).hexdigest()[:16])
Stallings & Brown, Computer Security 5e, ch3 §3.2