mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-05 11:00:56 +00:00
feat: improve argon2 security, (0.01s execution time in release mode, still fast)
This commit is contained in:
parent
f77cd2aa1c
commit
b142b3711f
1 changed files with 10 additions and 2 deletions
|
|
@ -35,7 +35,11 @@ pub fn random_8_char_string() -> String {
|
||||||
pub async fn hash_password(
|
pub async fn hash_password(
|
||||||
password_plain_text: String,
|
password_plain_text: String,
|
||||||
) -> Result<String, Box<dyn std::error::Error>> {
|
) -> Result<String, Box<dyn std::error::Error>> {
|
||||||
let argon_config = Argon2::default();
|
let argon_config = Argon2::new(
|
||||||
|
argon2::Algorithm::Argon2i,
|
||||||
|
argon2::Version::V0x13,
|
||||||
|
argon2::Params::new(6000, 3, 10, None)?,
|
||||||
|
);
|
||||||
|
|
||||||
let hash = tokio::task::spawn_blocking(move || {
|
let hash = tokio::task::spawn_blocking(move || {
|
||||||
let password = password_plain_text.as_bytes();
|
let password = password_plain_text.as_bytes();
|
||||||
|
|
@ -57,7 +61,11 @@ pub async fn verify_password(
|
||||||
password_plaint_text: String,
|
password_plaint_text: String,
|
||||||
hash: String,
|
hash: String,
|
||||||
) -> Result<bool, Box<dyn std::error::Error>> {
|
) -> Result<bool, Box<dyn std::error::Error>> {
|
||||||
let argon_config = Argon2::default();
|
let argon_config = Argon2::new(
|
||||||
|
argon2::Algorithm::Argon2i,
|
||||||
|
argon2::Version::V0x13,
|
||||||
|
argon2::Params::new(6000, 3, 10, None)?,
|
||||||
|
);
|
||||||
|
|
||||||
let result: Result<bool, argon2::password_hash::Error> =
|
let result: Result<bool, argon2::password_hash::Error> =
|
||||||
tokio::task::spawn_blocking(move || {
|
tokio::task::spawn_blocking(move || {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue