Crates.io | argon2-creds |
lib.rs | argon2-creds |
version | 0.2.3 |
source | src |
created_at | 2023-10-14 11:43:28.592697 |
updated_at | 2023-10-14 11:43:28.592697 |
description | Convenient abstractions for all things credentials |
homepage | https://git.batsense.net/realaravinth/argon2-creds |
repository | https://git.batsense.net/realaravinth/argon2-creds |
max_upload_size | |
id | 1003068 |
size | 325,795 |
Add this to your Cargo.toml
:
argon2-creds = "0.2"
Default
implementation for the default configuration.use argon2_creds::Config;
fn main() {
let config = Config::default();
let password = "ironmansucks";
// email validation
config.email(Some("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");
}
use argon2_creds::{Config, ConfigBuilder, PasswordPolicyBuilder};
fn main() {
let config = ConfigBuilder::default()
.username_case_mapped(false)
.profanity(true)
.blacklist(false)
.password_policy(
PasswordPolicyBuilder::default()
.min(12)
.max(80)
.build()
.unwrap(),
)
.build()
.unwrap();
let password = "ironmansucks";
let hash = config.password(password).unwrap();
// email validation
config.email(Some("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");
}