#argon2 #wrapper #async #config #run-time

bin+lib argon2-async

为 argon2 库提供的异步包装器

3 个不稳定版本

0.2.0 2022年4月18日
0.1.1 2021年12月6日
0.1.0 2021年12月6日

1784密码学

每月24次下载
用于 essence

MIT 许可证

18KB
250

argon2-async

此crate提供了一个相对不错的异步包装器,用于 argon2 crate.

用法

运行时

此crate对运行时不敏感。默认情况下,使用默认功能时,它使用 tokio 运行时,但可以进行更改。尽管如此,对其他运行时的支持在我的优先级列表中较低。

  • 要使用 tokio 作为底层运行时
[dependencies]
argon2-async = "0.1"
  • 要使用 async-std 作为底层运行时
[dependencies]
argon2-async = { version = "0.1", default-features = false, features = ["async-std-rt"] }
  • 要使用其他运行时
[dependencies]
argon2-async = { version = "0.1", default-features = false, features = ["any-rt"] }

代码用法

在您的代码中,请确保在尝试使用任何其他方法之前调用 argon2_async::set_config.

async fn main() {
    // It is *strongly* recommended to not use this as your default config,
    // as it is insecure.
    let config = argon2_async::Config::default();
    argon2_async::set_config(config).await.expect("setting config failed");
}

配置

默认配置非常不安全,但非常快,非常适合开发环境。内置了一个辅助工具来查找可用于生产的配置。要在生产机器(或具有等效硬件的机器)上使用它,请运行以下命令

git clone https://github.com/tazz4843/argon2-async
cd argon2-async
RUSTFLAGS="-Ctarget-cpu=native" cargo run --release

这将逐个测试一些配置设置,并在旁边有 👍 的都是适合生产的配置。

依赖关系

~4–5.5MB
~92K SLoC