Skip to content
C

Password Hashing and Verification

Easypython

Write hashpassword(password) and verifypassword(password, hashed) using bcrypt, and test verification with both a correct and an incorrect password.

Approach: hash the given password once with bcrypt.hashpw()/bcrypt.gensalt(), then check both a correct-attempt and a wrong-attempt string against that single hash with bcrypt.checkpw().

Input: Three lines: the real password, a "correct" login attempt, and a "wrong" login attempt.

Output: Two lines: "Correct attempt valid: True" and "Wrong attempt valid: False".

Input (stdin)

Output

Run your code to see output here...