argon2-creds/examples/simple.rs
Aravinth Manivannan e04d206475
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful
chore: update license
2023-10-14 17:09:50 +05:30

27 lines
747 B
Rust

// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
//
// SPDX-License-Identifier: AGPL-3.0-or-later
/* The easiest way to use this crate is with the default configuration.
* See `Default` implementation for the default configuration.
*/
use argon2_creds::Config;
fn main() {
let config = Config::default();
let password = "ironmansucks";
// email validation
config.email("batman@we.net").unwrap();
// 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 hashing");
}