No description
Aravinth Manivannan
db992117dd
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
|
||
---|---|---|
.github/workflows | ||
.reuse | ||
examples | ||
LICENSES | ||
src | ||
.gitignore | ||
.woodpecker.yml | ||
Cargo.lock | ||
Cargo.toml | ||
CHANGELOG.md | ||
README.md |
Features
- PRECIS Framework UsernameCaseMapped
- Password hashing and validation using rust-argon2
- Filters for words that might cause ambiguity. See Blacklist
- Profanity filter
- Email validation(Regex validation not verification)
Usage:
Add this to your Cargo.toml
:
argon2-creds = "0.2"
Examples:
- 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(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");
}
- To gain fine-grained control over how credentials are managed, consider using [ConfigBuilder]:
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");
}