Skip to content

Commit 864a29e

Browse files
ogarcia71
authored andcommitted
Deprecates numbers and renames it to digits
1 parent f3e80eb commit 864a29e

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ USAGE:
2020
2121
FLAGS:
2222
-L, --no-lower Exclude lowercase characters.
23-
-N, --no-numbers Exclude numbers.
23+
-D, --no-digits Exclude digits.
2424
-S, --no-symbols Exclude symbols.
2525
-U, --no-upper Exclude uppercase characters.
2626
-h, --help Prints help information

src/lib.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,24 @@ bitflags::bitflags! {
4141
pub struct CharacterSet: u8 {
4242
const Uppercase = 0b0001;
4343
const Lowercase = 0b0010;
44-
const Numbers = 0b0100;
44+
const Digits = 0b0100;
4545
const Symbols = 0b1000;
4646

4747
const Letters = Self::Uppercase.bits() | Self::Lowercase.bits();
48-
const All = Self::Letters.bits() | Self::Numbers.bits() | Self::Symbols.bits();
48+
const All = Self::Letters.bits() | Self::Digits.bits() | Self::Symbols.bits();
4949
}
5050
}
5151

5252
impl CharacterSet {
5353
const LOWERCASE: &'static str = "abcdefghijklmnopqrstuvwxyz";
5454
const UPPERCASE: &'static str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
55-
const NUMBERS: &'static str = "0123456789";
55+
const DIGITS: &'static str = "0123456789";
5656
const SYMBOLS: &'static str = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
5757

5858
/// Returns a string that contains all the characters that may be used to
5959
/// generate a password.
6060
pub const fn get_characters(self) -> &'static str {
61-
match (self.contains(Self::Lowercase), self.contains(Self::Uppercase), self.contains(Self::Numbers), self.contains(Self::Symbols)) {
61+
match (self.contains(Self::Lowercase), self.contains(Self::Uppercase), self.contains(Self::Digits), self.contains(Self::Symbols)) {
6262
(true , true , true , true ) => "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
6363
(true , true , true , false) => "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
6464
(true , true , false, true ) => "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
@@ -75,7 +75,7 @@ impl CharacterSet {
7575
(false, true , false, false) => Self::UPPERCASE,
7676

7777
(false, false, true , true ) => "0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
78-
(false, false, true , false) => Self::NUMBERS,
78+
(false, false, true , false) => Self::DIGITS,
7979
(false, false, false, true ) => Self::SYMBOLS,
8080

8181
_ => ""
@@ -99,8 +99,8 @@ impl CharacterSet {
9999
sets[sets_len] = Self::UPPERCASE;
100100
sets_len += 1;
101101
}
102-
if self.contains(Self::Numbers) {
103-
sets[sets_len] = Self::NUMBERS;
102+
if self.contains(Self::Digits) {
103+
sets[sets_len] = Self::DIGITS;
104104
sets_len += 1;
105105
}
106106
if self.contains(Self::Symbols) {

src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ pub struct Args {
7272
#[arg(short = 'U', long = "no-upper")]
7373
exclude_upper: bool,
7474

75-
/// Exclude numbers.
76-
#[arg(short = 'N', long = "no-numbers")]
77-
exclude_numbers: bool,
75+
/// Exclude digits.
76+
#[arg(short = 'D', long = "no-digits")]
77+
exclude_digits: bool,
7878

7979
/// Exclude symbols.
8080
#[arg(short = 'S', long = "no-symbols")]
@@ -116,7 +116,7 @@ fn run() -> Result<(), &'static str> {
116116
sha512,
117117
exclude_lower,
118118
exclude_upper,
119-
exclude_numbers,
119+
exclude_digits,
120120
exclude_symbols,
121121
return_entropy,
122122
print_fingerprint,
@@ -142,8 +142,8 @@ fn run() -> Result<(), &'static str> {
142142
if exclude_upper {
143143
charset.remove(CharacterSet::Uppercase);
144144
}
145-
if exclude_numbers {
146-
charset.remove(CharacterSet::Numbers);
145+
if exclude_digits {
146+
charset.remove(CharacterSet::Digits);
147147
}
148148
if exclude_symbols {
149149
charset.remove(CharacterSet::Symbols);

tests/blackbox.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn t(
4545
charset |= CharacterSet::Uppercase;
4646
}
4747
if digits {
48-
charset |= CharacterSet::Numbers;
48+
charset |= CharacterSet::Digits;
4949
}
5050
if symbols {
5151
charset |= CharacterSet::Symbols;

0 commit comments

Comments
 (0)