Crates.io | pants-gen |
lib.rs | pants-gen |
version | 0.3.0 |
source | src |
created_at | 2024-05-31 04:17:06.755549 |
updated_at | 2024-07-15 05:22:41.786205 |
description | A password generator. |
homepage | |
repository | https://github.com/BenPski/pants-gen |
max_upload_size | |
id | 1257633 |
size | 29,026 |
Password generator, used for pants.
A password generator that can be used as a library or at the command line
When using from the command line can either provide a spec string, or override the default (or current spec string) with other arguments.
Using the default spec
$ pants-gen
PHk};IUX{59!H88252x4wjD(Fg|5cva|
Overriding the default spec to be:
$ pants-gen --spec '16//3+|:upper://1-2|:lower://3-|:number://1|:symbol:'
8Z6TWWCARwJxC)8C
Overriding parts of the default spec
$ pants-gen -l 12
bS),2VMV2G+T
Setting custom charater groups
$ pants-gen -s 0 -c '!@#$%^&*|_+-=|1+'
=LsI8=%@%GP5hMlIm%#dj9&66V9-#7h@
To generate a password build up the spec and then call generate
to produce the password. This
function returns an Option
since the constraints on the provided choices can't always meet
the length requirement given.
use pants_gen::password::{PasswordSpec, CharStyle};
use pants_gen::interval::Interval;
let spec = PasswordSpec::new()
.length(16)
.upper_at_least(1)
.lower(Interval::new(1,10).unwrap())
.include(CharStyle::Number.exactly(3))
.custom(vec!['&', '^'], Interval::exactly(1));
if let Some(p) = spec.generate() {
println!("{}", p);
} else {
println!("Couldn't meet constraints of spec");
}