Skip to content

Commit e52f340

Browse files
authored
yescrypt: basic usage documentation (#676)
1 parent b3e3008 commit e52f340

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

yescrypt/src/lib.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,33 @@
2121
unused_qualifications
2222
)]
2323

24+
//! # Usage
25+
//! ## Password Hashing
26+
//! NOTE: the `simple` crate feature must be enabled (on-by-default)
27+
#![cfg_attr(feature = "simple", doc = "```")]
28+
#![cfg_attr(not(feature = "simple"), doc = "```ignore")]
29+
//! # fn main() -> yescrypt::Result<()> {
30+
//! let password = b"pleaseletmein"; // don't actually use this as a password!
31+
//! let salt = b"WZaPV7LSUEKMo34."; // unique per password, ideally 16-bytes and random
32+
//! let password_hash = yescrypt::yescrypt(password, salt, &Default::default())?;
33+
//! assert_eq!(&password_hash[..3], "$y$");
34+
//! # Ok(())
35+
//! # }
36+
//! ```
37+
//!
38+
//! ## Key Derivation Function (KDF)
39+
#![cfg_attr(feature = "simple", doc = "```")]
40+
#![cfg_attr(not(feature = "simple"), doc = "```ignore")]
41+
//! # fn main() -> yescrypt::Result<()> {
42+
//! let password = b"pleaseletmein"; // don't actually use this as a password!
43+
//! let salt = b"WZaPV7LSUEKMo34."; // unique per password, ideally 16-bytes and random
44+
//!
45+
//! let mut output = [0u8; 32]; // can be sized as desired
46+
//! yescrypt::yescrypt_kdf(password, salt, &Default::default(), &mut output)?;
47+
//! # Ok(())
48+
//! # }
49+
//! ```
50+
2451
// Adapted from the yescrypt reference implementation available at:
2552
// <https://github.com/openwall/yescrypt>
2653
//

0 commit comments

Comments
 (0)