
Wikis & learning
Verify a stored password without revealing it
An account should store a password hash produced by the password API. During sign-in compare the user's input against that stored hash.
An account should store a password hash produced by the password API. During sign-in compare the user's input against that stored hash.
Walkthrough
The hashing function selects a salt and includes its settings in the stored value. A later verification uses that information directly. The exercise prints only boolean outcomes, so the output is deterministic even though the generated hash changes.
PHP example
<?php
$stored = password_hash('practice phrase one', PASSWORD_DEFAULT);
foreach (['practice phrase one', 'practice phrase two'] as $guess) {
echo password_verify($guess, $stored) ? 'Match' : 'No match', PHP_EOL;
}Expected output
Match
No matchChange and check
Generate the same password hash twice and compare the returned strings privately. Verify both hashes against the original input and explain the results.
Discussion
Sign in to participate.



