Skip to content
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

the rust argon2 implementation is ~76 times slower than the golang implementation #408

Closed
zlianon opened this issue Apr 4, 2023 · 1 comment

Comments

@zlianon
Copy link

zlianon commented Apr 4, 2023

Rust (cargo run: ~2m33s)

use argon2::Algorithm;
use argon2::Argon2;
use argon2::ParamsBuilder;
use argon2::Version;
use rand::thread_rng;
use rand::RngCore;

fn main() {
    let mut salt = [0u8; 16];
    thread_rng().fill_bytes(&mut salt);
    let mut key = [0u8; 32];
    Argon2::new(
        Algorithm::Argon2id,
        Version::V0x13,
        ParamsBuilder::new()
            .m_cost(1048576)
            .t_cost(12)
            .p_cost(8)
            .build()
            .unwrap_or_else(|error| panic!("{}", error)),
    )
    .hash_password_into(b"password", &salt, &mut key)
    .unwrap_or_else(|error| panic!("{}", error));
}

Go (go run: ~2s)

package main

import (
	"crypto/rand"
	"golang.org/x/crypto/argon2"
)

func main() {
	salt := make([]byte, 16)
	rand.Read(salt)
	argon2.IDKey([]byte("password"), salt, 12, 1048576, 8, 32)
}
@tarcieri
Copy link
Member

tarcieri commented Apr 4, 2023

See #104

@tarcieri tarcieri closed this as not planned Won't fix, can't repro, duplicate, stale Apr 5, 2023
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

No branches or pull requests

2 participants