pants_gen/lib.rs
1//! Password generation library used in `pants`
2//!
3//! When using from the command line can either provide a spec string, or override the default (or
4//! current spec string) with other arguments.
5//!
6//!
7//! # CLI examples (requires pants to be installed)
8//! Using the default spec
9//! ```bash
10//! $ pants gen
11//! PHk};IUX{59!H88252x4wjD(Fg|5cva|
12//! ```
13//!
14//! Overriding the default spec to be:
15//! - 3 or more uppercase letters
16//! - 1 to 2 lowercase letters
17//! - 3 or fewer numbers
18//! - 1 symbol
19//! - password of length 16
20//! ```bash
21//! $ pants gen --spec '16//3+|:upper://1-2|:lower://3-|:number://1|:symbol:'
22//! 8Z6TWWCARwJxC)8C
23//! ```
24//!
25//! Overriding parts of the default spec
26//! - setting the length to be 12
27//! ```bash
28//! $ pants gen -l 12
29//! bS),2VMV2G+T
30//! ```
31//!
32//! Setting custom charater groups
33//! - disabling the symbols
34//! - setting an equivalent set of symbols to be !@#$%^&*|_+-=
35//! ```bash
36//! $ pants gen -s 0 -c '!@#$%^&*|_+-=|1+'
37//! =LsI8=%@%GP5hMlIm%#dj9&66V9-#7h@
38//! ```
39//!
40//! # Library examples
41//!
42//! To generate a password build up the spec and then call `generate` to produce the password. This
43//! function returns an `Option` since the constraints on the provided choices can't always meet
44//! the length requirement given.
45//! ```rust
46//! use pants_gen::charset::Charset;
47//! use pants_gen::password::PasswordSpec;
48//! use pants_gen::interval::Interval;
49//! let spec = PasswordSpec::new()
50//! .length(16)
51//! .upper_at_least(1)
52//! .lower(Interval::new(1,10).unwrap())
53//! .include(Charset::Number.exactly(3))
54//! .custom(vec!['&', '^'], Interval::exactly(1));
55//! if let Some(p) = spec.generate() {
56//! println!("{}", p);
57//! } else {
58//! println!("Couldn't meet constraints of spec");
59//! }
60//! ```
61pub mod charset;
62pub mod choice;
63pub mod interval;
64pub mod password;