mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-13 12:16:54 +00:00
chore: upgrade argon2
This commit is contained in:
4 files changed
+33
-27
No files matched your search
@@ -88,8 +88,6 @@ log.workspace = true
|
||||
lettre.workspace = true
|
||||
num-traits.workspace = true
|
||||
rand.workspace = true
|
||||
# tied to passwordhash 0.5.0
|
||||
rand_core = { version = "0.6.4", features = ["getrandom"] }
|
||||
regex.workspace = true
|
||||
reqwest.workspace = true
|
||||
sha2.workspace = true
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::sync::OnceLock;
|
||||
|
||||
use argon2::{
|
||||
Algorithm, Argon2, Params, PasswordHash, PasswordHasher, PasswordVerifier, Version,
|
||||
password_hash, password_hash::SaltString,
|
||||
password_hash,
|
||||
};
|
||||
|
||||
use crate::{Error, Result, err};
|
||||
@@ -28,16 +28,15 @@ fn init_argon() -> Argon2<'static> {
|
||||
}
|
||||
|
||||
pub(super) fn password(password: &str) -> Result<String> {
|
||||
let salt = SaltString::generate(rand_core::OsRng);
|
||||
ARGON
|
||||
.get_or_init(init_argon)
|
||||
.hash_password(password.as_bytes(), &salt)
|
||||
.hash_password(password.as_bytes())
|
||||
.map(|it| it.to_string())
|
||||
.map_err(map_err)
|
||||
}
|
||||
|
||||
pub(super) fn verify_password(password: &str, password_hash: &str) -> Result<()> {
|
||||
let password_hash = PasswordHash::new(password_hash).map_err(map_err)?;
|
||||
let password_hash = PasswordHash::new(password_hash).map_err(|e| map_err(e.into()))?;
|
||||
ARGON
|
||||
.get_or_init(init_argon)
|
||||
.verify_password(password.as_bytes(), &password_hash)
|
||||
|
||||
Reference in new issue
Block a user