3 releases (1 stable)
new 1.0.0 | Oct 10, 2024 |
---|---|
0.2.0 | Oct 9, 2024 |
0.1.0 | Oct 9, 2024 |
#542 in Cryptography
94 downloads per month
90KB
278 lines
Cryptirust
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.
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);
let (passphrase, entropy) = generator.gen_from_pattern("w.w.w.w");;
println!("Generated passphrase: {}", passphrase);
println!("Entropy: {:.2} bits", entropy);
}
Command Line Interface is included with the library
This CLI allows users to specify a pattern for the generated passphrases, the number of passphrases to generate and the depth of the markov model.
Usage
To run the CLI, first cargo install cryptirust
, then use the following command:
cryptirust [PATTERN] [NUM] [DEPTH]
- PATTERN: A string representing the desired structure of the generated
passphrases, default is
w-c-s-d
(i.e. word-token-symbol-digit). - NUM: The number of passphrases to generate. Must be a positive integer.
Default is
5
. - DEPTH: The depth of the markov model. Must be a positive integer.
Default is
3
.
Examples
Generate five passphrases with the default pattern:
cryptirust
n. log2(guesses) secret
1 29.83 stingly-rak-+-5
2 34.93 attinge-roy-+-5
3 26.01 whomever-sta-"-3
4 31.29 laddering-gre-^-5
5 30.09 renditzy-sha-%-5
Generate six passphrases with a custom pattern "w.w.w" and a custom depth 2:
cryptirust w.w.w 6 2
n. log2(guesses) secret
1 57.60 gontex.atiness.unteet
2 67.70 casuperl.cacharne.aneyway
3 60.03 choomeg.deflanth.nessagre
4 53.64 vishelaw.gedity.wildness
5 58.19 dulays.frishea.queure
6 56.36 partifie.deligeom.refullyi
License
Cryptirust is licensed under the MIT License.
Dependencies
~1.3–2MB
~37K SLoC