Password Maker
This is a password generation library for Rust.
Usage
Generate a password with the default settings
The default settings are as follows:
use password_maker::PasswordMaker;
fn main() {
let mut password_maker = PasswordMaker::default();
let password = password_maker.generate().unwrap();
println!("{}", password); }
Specify the length of the password
You can specify the length of the password as follows:
use password_maker::PasswordMaker;
fn main() {
let mut password_maker = PasswordMaker {
length: 20,
..Default::default()
};
let password = password_maker.generate().unwrap();
println!("{}", password); }
Specify symbols
You can change the symbols as follows:
use password_maker::PasswordMaker;
fn main() {
let mut password_maker = PasswordMaker::default();
password_maker.symbols.candidates = vec!["@".to_string(), "^".to_string()];
let password = password_maker.generate().unwrap();
println!("{}", password); }
Specify the minimum number of occurrences
You can specify the minimum number of times a character appears as follows:
use password_maker::PasswordMaker;
fn main() {
let mut password_maker = PasswordMaker::default();
password_maker.symbols.minimum_count = 10;
let password = password_maker.generate().unwrap();
println!("{}", password); }
Generate a password with only lowercases, excluding symbols, uppercases, and numbers
You can exclude symbols as follows:
use password_maker::PasswordMaker;
fn main() {
let mut password_maker = PasswordMaker::default();
password_maker.uppercases.candidates = vec![];
password_maker.uppercases.minimum_count = 0; password_maker.numbers.candidates = vec![];
password_maker.numbers.minimum_count = 0;
password_maker.symbols.candidates = vec![];
password_maker.symbols.minimum_count = 0;
let password = password_maker.generate().unwrap();
println!("{}", password); }
Add emojis and other characters as candidates
You can add emojis and other characters as candidates as follows:
use password_maker::PasswordMaker;
fn main() {
let mut password_maker = PasswordMaker::default();
password_maker.other_characters.candidates = vec![
'π', 'π', 'π', 'π€£', 'π', 'π', 'π
', 'π', 'π', 'π', 'π', 'π', 'π', 'π', 'π',
'δΈ', 'δΊ', 'δΈ', 'ε', 'δΊ', 'ε
', 'δΈ', 'ε
«', 'δΉ', 'ε',
];
let password = password_maker.generate().unwrap();
println!("{}", password); }
License
The password-maker project is licensed under both the Apache License, Version 2.0 and the MIT License.
You may select, at your option, one of the above-listed licenses.
See the LICENSE-APACHE and LICENSE-MIT files for the full text of the Apache License, Version 2.0 and the MIT License, respectively.