Skip to content

Update dependencies of the examples #3931

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

joeydewaal
Copy link
Contributor

This pr updates the dependencies of the examples.

Does your PR solve an issue?

fixes #3772

Is this a breaking change?

no, only the examples are updated

@abonander
Copy link
Collaborator

Does this not update the Cargo.lock?

@joeydewaal
Copy link
Contributor Author

Forgot to git add it

use tokio::task;

use argon2::password_hash::SaltString;
use argon2::{password_hash, Argon2, PasswordHash, PasswordHasher, PasswordVerifier};

pub async fn hash(password: String) -> anyhow::Result<String> {
task::spawn_blocking(move || {
let salt = SaltString::generate(rand::thread_rng());
let salt = SaltString::generate(&mut OsRng);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argon2 and password-hash have release-candidate versions out that are compatible with rand-core 0.9.

I don't know exactly when they plan on publishing full releases, but it might be better to wait for that.

Alternatively, instead of hacking around the incompatibility by using the old version of rand, this could show how to generate a SaltString from any version of rand:

// `SaltString::generate()` is only compatible with `rand 0.6`, which is very out-of-date now.
// This shows how to generate a salt using nearly any `rand` version.
let salt: [u8; Salt::RECOMMENDED_LENGTH] = rand::random();

let salt = SaltString::encode_b64(&salt)
    .expect("should not fail; we generated a salt of recommended length");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That snippet is indeed more convenient. I added that but it's 3 examples that have this problem so it might be better to wait this out, not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RUSTSEC-2024-0421
2 participants