argon2-creds/examples/simple.rs

24 lines
617 B
Rust
Raw Normal View History

2021-03-04 20:51:06 +05:30
/* The easiest way to use this crate is with the default configuration.
* See `Default` implementation for the default configuration.
*/
2021-01-29 11:42:59 +05:30
use argon2_creds::Config;
fn main() {
let config = Config::default();
let password = "ironmansucks";
// email validation
2021-04-13 23:11:34 +05:30
config.email("batman@we.net").unwrap();
2021-01-29 11:42:59 +05:30
// process username
let username = config.username("Realaravinth").unwrap(); // process username
// generate hash
let hash = config.password(password).unwrap();
assert_eq!(username, "realaravinth");
assert!(Config::verify(&hash, password).unwrap(), "verify hahsing");
}