2021-11-28 11:40:50 +01:00
|
|
|
import crypto.bcrypt
|
|
|
|
|
|
|
|
fn test_crypto_bcrypt() {
|
|
|
|
hash := bcrypt.generate_from_password('password'.bytes(), 10) or { panic(err) }
|
|
|
|
|
|
|
|
bcrypt.compare_hash_and_password('password'.bytes(), hash.bytes()) or { panic(err) }
|
|
|
|
|
|
|
|
bcrypt.compare_hash_and_password('password2'.bytes(), hash.bytes()) or {
|
2022-02-11 14:52:33 +01:00
|
|
|
assert err.msg() == 'mismatched hash and password'
|
2021-11-28 11:40:50 +01:00
|
|
|
}
|
|
|
|
}
|