Crates.io | password-maker |
lib.rs | password-maker |
version | 0.1.2 |
source | src |
created_at | 2024-10-23 13:25:05.337842 |
updated_at | 2024-10-24 16:56:13.814731 |
description | Highly customizable password generation library.π |
homepage | https://github.com/yutotnh/mkpw/tree/main/password-maker |
repository | https://github.com/yutotnh/mkpw/tree/main/password-maker |
max_upload_size | |
id | 1420115 |
size | 67,722 |
This is a password generation library for Rust.
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); // => 8m8s]@IV[d=2\f_(
}
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); // => /(DBnw!pv4@"(ku|)/rx
}
You can change the symbols as follows:
use password_maker::PasswordMaker;
fn main() {
let mut password_maker = PasswordMaker::default();
password_maker.symbol.candidates = vec!["@".to_string(), "^".to_string()];
let password = password_maker.generate().unwrap();
println!("{}", password); // => dHt^fO5fzgR@X4EC
}
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.symbol.minimum_count = 10;
let password = password_maker.generate().unwrap();
println!("{}", password); // => ZS^('}):?l}$<$|2
}
You can exclude symbols as follows:
use password_maker::PasswordMaker;
fn main() {
let mut password_maker = PasswordMaker::default();
password_maker.uppercase.candidates = vec![];
password_maker.uppercase.minimum_count = 0; // If candidates are empty, min must be 0, otherwise it will result in an error
password_maker.number.candidates = vec![];
password_maker.number.minimum_count = 0;
password_maker.symbol.candidates = vec![];
password_maker.symbol.minimum_count = 0;
let password = password_maker.generate().unwrap();
println!("{}", password); // => tfpwxjzudvaibnwg
}
You can add emojis and other characters as candidates as follows:
use password_maker::{Classifier, PasswordMaker};
fn main() {
let mut password_maker = PasswordMaker {
others: vec![Classifier {
candidates: [
'π', 'π', 'π', 'π€£', 'π', 'π', 'π
', 'π', 'π', 'π', 'π', 'π', 'π', 'π',
'π', 'δΈ', 'δΊ', 'δΈ', 'ε', 'δΊ', 'ε
', 'δΈ', 'ε
«', 'δΉ', 'ε',
]
.iter()
.map(|&c| c.to_string())
.collect(),
minimum_count: 1,
}],
..Default::default()
};
let password = password_maker.generate().unwrap();
println!("{}", password); // => ?π€£-δΊπ7=0*πr}Nta>
}
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.