Skip to content

Commit 0395f07

Browse files
committed
improve error message
1 parent fa46e63 commit 0395f07

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/_bcrypt/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ fn hashpw<'p>(
7878
// bytes on the updated prefix $2b$, but leaving $2a$ unchanged for
7979
// compatibility. However, pyca/bcrypt 2.0.0 *did* correctly truncate inputs
8080
// on $2a$, so we do it here to preserve compatibility with 2.0.0
81-
// Silent truncation is _probably_ not the best idea, even if the "original"
81+
// Silent truncation is _probably_ not the best idea, even if the "original"
8282
// OpenBSD implementation did/does this.
8383
// We prefer to raise a ValueError in this case - if the user _wants_ to truncate,
8484
// they can always do so manually by passing s[:72] instead of s into hashpw().
8585

8686
if password.len() > 72 {
8787
return Err(pyo3::exceptions::PyValueError::new_err(
88-
"Password cannot be longer than 72 bytes",
88+
"password cannot be longer than 72 bytes, truncate manually if necessary (e.g. my_password[:72])",
8989
));
9090
}
9191

0 commit comments

Comments
 (0)