#password-generator #password #generator #pronounceable #markov-chain #library #cli

bin+lib cryptirust

A flexible password generator that creates pronounceable passwords with adjustable entropy and custom patterns

6 releases (stable)

2.0.2 Oct 12, 2024
1.0.0 Oct 10, 2024
0.2.0 Oct 9, 2024
0.1.0 Oct 9, 2024

#382 in Value formatting

MIT license

160KB
343 lines

Cryptirust

Crates.io MIT licensed Build Status API Docs

Cryptirust is a flexible and efficient Rust library for generating customizable, pronounceable passwords with entropy calculation. It leverages a Markov chain-based approach through its core Generator struct, allowing you to construct secure passphrases and word-based passwords from predefined or user-defined token lists.

Designed to balance security, usability, and flexibility, Cryptirust offers fine-grained control over the structure and randomness of passwords. Whether you're creating simple, memorable passphrases or complex high-entropy passwords, Cryptirust provides an intuitive API to meet a range of password generation needs.

Key Features

  • Pronounceable Passwords: Create easy-to-pronounce, memorable passwords using phonetic patterns.
  • Entropy Calculation: Automatically calculates and returns the entropy of each generated password, helping you gauge its strength.
  • Custom Token Support: Define custom token sets and adjust the depth of the Markov chain model for even greater control over password structure.
  • Pattern Flexibility: Generate passphrases, pseudo-words, and custom patterns that can include symbols, numbers, and more.
  • CLI: most functions of cryptirust are easily accessible from Crypticli.

Quick start

1. Generate a Password from a Custom Pattern

Use a pattern string to create complex passwords:

  • c: Lowercase token.
  • C: Uppercase token.
  • w: Lowercase word.
  • W: Uppercase word.
  • s: Symbol.
  • d: Digit.
  • \: Escape next character.
use cryptirust::Generator;

fn main() {
    let mut generator = Generator::new();
    let (password, entropy) = generator.gen_from_pattern("cccsd");
    println!("Generated password: {}", password);
    println!("Entropy: {:.2} bits", entropy);
}

2. Generate a Passphrase with Custom Depth

use cryptirust::*;

fn main() {
    let mut generator = Generator::new_custom(word_list::eff::list(), 2).unwrap();
    let (passphrase, entropy) = generator.gen_from_pattern("w.w.w.w");;
    println!("Generated passphrase: {}", passphrase);
    println!("Entropy: {:.2} bits", entropy);
}

License

Cryptirust is licensed under the MIT License.

Dependencies

~1.4–2.3MB
~42K SLoC