README.md
1# Rust-argon2
2
3Rust library for hashing passwords using
4[Argon2](https://github.com/P-H-C/phc-winner-argon2), the password-hashing
5function that won the
6[Password Hashing Competition (PHC)](https://password-hashing.net).
7
8## Usage
9
10To use `rust-argon2`, add the following to your Cargo.toml:
11
12```toml
13[dependencies]
14rust-argon2 = "0.7"
15```
16
17And the following to your crate root:
18
19```rust
20extern crate argon2;
21```
22
23
24## Examples
25
26Create a password hash using the defaults and verify it:
27
28```rust
29use argon2::{self, Config};
30
31let password = b"password";
32let salt = b"randomsalt";
33let config = Config::default();
34let hash = argon2::hash_encoded(password, salt, &config).unwrap();
35let matches = argon2::verify_encoded(&hash, password).unwrap();
36assert!(matches);
37```
38
39Create a password hash with custom settings and verify it:
40
41```rust
42use argon2::{self, Config, ThreadMode, Variant, Version};
43
44let password = b"password";
45let salt = b"othersalt";
46let config = Config {
47 variant: Variant::Argon2i,
48 version: Version::Version13,
49 mem_cost: 65536,
50 time_cost: 10,
51 lanes: 4,
52 thread_mode: ThreadMode::Parallel,
53 secret: &[],
54 ad: &[],
55 hash_length: 32
56};
57let hash = argon2::hash_encoded(password, salt, &config).unwrap();
58let matches = argon2::verify_encoded(&hash, password).unwrap();
59assert!(matches);
60```
61
62
63## Limitations
64
65This crate has the same limitation as the `blake2-rfc` crate that it uses.
66It does not attempt to clear potentially sensitive data from its work
67memory. To do so correctly without a heavy performance penalty would
68require help from the compiler. It's better to not attempt to do so than to
69present a false assurance.
70
71This version uses the standard implementation and does not yet implement
72optimizations. Therefore, it is not the fastest implementation available.
73
74
75## License
76
77Rust-argon2 is dual licensed under the [MIT](LICENSE-MIT) and
78[Apache 2.0](LICENSE-APACHE) licenses, the same licenses as the Rust compiler.
79
80
81## Contributions
82
83Contributions are welcome. By submitting a pull request you are agreeing to
84make you work available under the license terms of the Rust-argon2 project.
85
86