In my Cargo.toml, want to upgrade argon2-rs from 0.5
to 0.5.3
, but I get an error that I can't seem to solve myself:
use argon2::password_hash::rand_core::OsRng;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `OsRng` in the root
When I follow the compiler hint to use rand::rngs::OsRng;
instead, then I can't generate password hashes with my existing code:
let salt = SaltString::generate(&mut OsRng);
-------------------- ^^^^^ the trait `argon2::password_hash::rand_core::CryptoRng` is not implemented for `rand::rngs::OsRng`
note: there are multiple different versions of crate `rand_core` in the dependency graph
In my code I already use rand 0.9
which is the same version as other crates like postgres-rs. But only one crate chrono-tz 0.10.1
is still using rand 0.8.5
.
Currently I can only revert back to rand 0.8
.
How can I upgrade to rand 0.9
?
The trait argon2::password_hash::rand_core::CryptoRng
is not implemented for rand::rngs::OsRng
A solution would be to utilize other functions to achieve the same thing:
let mut bytes = [0u8; Salt::RECOMMENDED_LENGTH];
OsRng.try_fill_bytes(&mut bytes).unwrap();
let salt = SaltString::encode_b64(&bytes).unwrap();