When password has more than 72 bytes, it is truncated and the assumption may not hold true.
I wonder if L109 is necessary.
|
// Passwords need to be null terminated |
|
let mut vec = Vec::with_capacity(password.len() + 1); |
|
vec.extend_from_slice(password); |
|
vec.push(0); |
|
// We only consider the first 72 chars; truncate if necessary. |
|
// `bcrypt` below will panic if len > 72 |
|
let truncated = if vec.len() > 72 { &vec[..72] } else { &vec }; |
|
|
|
let output = bcrypt::bcrypt(cost, salt, truncated); |
When
passwordhas more than 72 bytes, it is truncated and the assumption may not hold true.I wonder if L109 is necessary.
rust-bcrypt/src/lib.rs
Lines 106 to 114 in b6af5e5