mirror of
https://github.com/vlang/v.git
synced 2025-08-03 17:57:59 -04:00
crypto.bcrypt: reduce runtime cost for running bcrypt_test.v, by reducing the iteration count
This commit is contained in:
parent
b656481f62
commit
747f3b3c4c
@ -1,21 +1,17 @@
|
||||
import crypto.bcrypt
|
||||
|
||||
fn test_crypto_bcrypt() {
|
||||
bcrypt.compare_hash_and_password('123456'.bytes(), '$2y$13$7j2kgHgrEiI9kYmiXZuiyu3IJFWXEH.sZN6ai82XNCd9SZ7UwdlTW'.bytes()) or {
|
||||
panic(err)
|
||||
}
|
||||
bcrypt.compare_hash_and_password('123456'.bytes(), r'$2a$07$MRniCPEgEQnrJmmgN.maM.kF2a/TI2PB37EQQNsUtEuINwultcHTm'.bytes())!
|
||||
|
||||
hash := bcrypt.generate_from_password('password'.bytes(), 10) or { panic(err) }
|
||||
|
||||
bcrypt.compare_hash_and_password('password'.bytes(), hash.bytes()) or { panic(err) }
|
||||
hash := bcrypt.generate_from_password('password'.bytes(), 5)!
|
||||
bcrypt.compare_hash_and_password('password'.bytes(), hash.bytes())!
|
||||
|
||||
bcrypt.compare_hash_and_password('password2'.bytes(), hash.bytes()) or {
|
||||
assert err.msg() == 'mismatched hash and password'
|
||||
}
|
||||
|
||||
hash2 := bcrypt.generate_from_password('bb'.bytes(), 10) or { panic(err) }
|
||||
hash2 := bcrypt.generate_from_password('bb'.bytes(), 5)!
|
||||
mut hash2_must_mismatch := false
|
||||
|
||||
bcrypt.compare_hash_and_password('bbb'.bytes(), hash2.bytes()) or {
|
||||
hash2_must_mismatch = true
|
||||
assert err.msg() == 'mismatched hash and password'
|
||||
|
Loading…
x
Reference in New Issue
Block a user