parent
cd4229d64c
commit
e1ed0f46ca
@ -49,7 +49,9 @@ fn hashpass<'p>(
|
||||
.try_into()
|
||||
.map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?;
|
||||
|
||||
let hashed = py.allow_threads(|| bcrypt::hash_with_salt(password, cost, raw_salt).unwrap());
|
||||
let hashed = py
|
||||
.allow_threads(|| bcrypt::hash_with_salt(password, cost, raw_salt))
|
||||
.map_err(|_| pyo3::exceptions::PyValueError::new_err("Invalid salt"))?;
|
||||
Ok(pyo3::types::PyBytes::new(
|
||||
py,
|
||||
hashed.format_for_version(version).as_bytes(),
|
||||
|
||||
@ -272,6 +272,11 @@ def test_checkpw_bad_salt():
|
||||
b"badpass",
|
||||
b"$2b$04$?Siw3Nv3Q/gTOIPetAyPr.GNj3aO0lb1E5E9UumYGKjP9BYqlNWJe",
|
||||
)
|
||||
with pytest.raises(ValueError):
|
||||
bcrypt.checkpw(
|
||||
b"password",
|
||||
b"$2b$3$mdEQPMOtfPX.WGZNXgF66OhmBlOGKEd66SQ7DyJPGucYYmvTJYviy",
|
||||
)
|
||||
|
||||
|
||||
def test_checkpw_str_password():
|
||||
|
||||
Loading…
Reference in New Issue
Block a user