No description
Find a file
Renovate Bot 8ab50030fc
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pull_request_closed/woodpecker Pipeline was successful
fix(deps): update rust crate regex to v1.10.6
2024-08-02 16:00:20 +00:00
.github/workflows chore: CI: bump deps 2022-02-09 19:40:45 +05:30
.reuse chore: update license 2023-10-14 17:09:50 +05:30
examples chore: update license 2023-10-14 17:09:50 +05:30
LICENSES chore: update license 2023-10-14 17:09:50 +05:30
src chore: update license 2023-10-14 17:09:50 +05:30
.gitignore chore: bump deps 2022-02-09 19:40:33 +05:30
.woodpecker.yml feat: mv to git.batsense.net 2023-10-14 16:39:45 +05:30
Cargo.lock fix(deps): update rust crate regex to v1.10.6 2024-08-02 16:00:20 +00:00
Cargo.toml fix(deps): update rust crate validator to 0.18 2024-06-08 15:17:03 +00:00
CHANGELOG.md chore: update license 2023-10-14 17:09:50 +05:30
README.md feat: link docs 2023-10-14 17:20:58 +05:30
renovate.json Add renovate.json 2024-06-08 10:45:10 +00:00

Argon2-Creds

Argon2-Creds - convenient abstractions for managing credentials

Documentation status-badge dependency status

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:

  1. 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");
}
  1. 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");
}