-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
base: main
Are you sure you want to change the base?
Changes from 7 commits
5b7d118
bb61d8d
0ba5b66
181f65e
544e177
08af881
050b3a7
39e7ca7
49cedf8
8769b58
e5d8b2a
f56d380
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
use anyhow::{anyhow, Context}; | ||
use argon2::password_hash::rand_core::OsRng; | ||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
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 // `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"); There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
Ok(Argon2::default() | ||
.hash_password(password.as_bytes(), &salt) | ||
.map_err(|e| anyhow!(e).context("failed to hash password"))? | ||
|
Uh oh!
There was an error while loading. Please reload this page.