zxcvbn 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/zxcvbn/adjacency_graphs.rb +219 -219
- data/lib/zxcvbn/matching.rb +34 -40
- data/lib/zxcvbn/scoring.rb +6 -6
- data/lib/zxcvbn/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f102d8ba269aad3742c05649bbb698c01d639ee794c8adc9abe66fb285674f42
|
4
|
+
data.tar.gz: 2f01f158959ed48ad413bb91970c7824efeb42392aca97b91e4d1be50a149e47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c05246356ff182b57ca9acd01b6ee95269c4264a5d9cb1d947229de9ee9974e30a3860e4d860cec946c1ef22d9d9baa90dcf2f89bf843d8f5c749b3a0d64867c
|
7
|
+
data.tar.gz: 1dc9944425d5a9105ebe59eb0b1dab1a06bb98ff94e032b476714ebc23281560ea78a0ffebb4a086f7da42a6fdcd1502f296a1f45f84d94b99d63461d00c25eb
|
data/README.md
CHANGED
@@ -75,7 +75,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
75
75
|
|
76
76
|
## Contributing
|
77
77
|
|
78
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
78
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/formigarafa/zxcvbn. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/zxcvbn/blob/master/CODE_OF_CONDUCT.md).
|
79
79
|
|
80
80
|
## License
|
81
81
|
|
@@ -4,231 +4,231 @@
|
|
4
4
|
module Zxcvbn
|
5
5
|
ADJACENCY_GRAPHS = {
|
6
6
|
qwerty: {
|
7
|
-
"!"
|
8
|
-
"\""
|
9
|
-
"#"
|
10
|
-
"$"
|
11
|
-
"%"
|
12
|
-
"&"
|
13
|
-
"'"
|
14
|
-
"("
|
15
|
-
")"
|
16
|
-
"*"
|
17
|
-
"+"
|
18
|
-
","
|
19
|
-
"-"
|
20
|
-
"."
|
21
|
-
"/"
|
22
|
-
"0"
|
23
|
-
"1"
|
24
|
-
"2"
|
25
|
-
"3"
|
26
|
-
"4"
|
27
|
-
"5"
|
28
|
-
"6"
|
29
|
-
"7"
|
30
|
-
"8"
|
31
|
-
"9"
|
32
|
-
":"
|
33
|
-
";"
|
34
|
-
"<"
|
35
|
-
"="
|
36
|
-
">"
|
37
|
-
"?"
|
38
|
-
"@"
|
39
|
-
"A"
|
40
|
-
"B"
|
41
|
-
"C"
|
42
|
-
"D"
|
43
|
-
"E"
|
44
|
-
"F"
|
45
|
-
"G"
|
46
|
-
"H"
|
47
|
-
"I"
|
48
|
-
"J"
|
49
|
-
"K"
|
50
|
-
"L"
|
51
|
-
"M"
|
52
|
-
"N"
|
53
|
-
"O"
|
54
|
-
"P"
|
55
|
-
"Q"
|
56
|
-
"R"
|
57
|
-
"S"
|
58
|
-
"T"
|
59
|
-
"U"
|
60
|
-
"V"
|
61
|
-
"W"
|
62
|
-
"X"
|
63
|
-
"Y"
|
64
|
-
"Z"
|
65
|
-
"["
|
66
|
-
"\\"
|
67
|
-
"]"
|
68
|
-
"^"
|
69
|
-
"_"
|
70
|
-
"`"
|
71
|
-
"a"
|
72
|
-
"b"
|
73
|
-
"c"
|
74
|
-
"d"
|
75
|
-
"e"
|
76
|
-
"f"
|
77
|
-
"g"
|
78
|
-
"h"
|
79
|
-
"i"
|
80
|
-
"j"
|
81
|
-
"k"
|
82
|
-
"l"
|
83
|
-
"m"
|
84
|
-
"n"
|
85
|
-
"o"
|
86
|
-
"p"
|
87
|
-
"q"
|
88
|
-
"r"
|
89
|
-
"s"
|
90
|
-
"t"
|
91
|
-
"u"
|
92
|
-
"v"
|
93
|
-
"w"
|
94
|
-
"x"
|
95
|
-
"y"
|
96
|
-
"z"
|
97
|
-
"{"
|
98
|
-
"|"
|
99
|
-
"}"
|
100
|
-
"~"
|
7
|
+
"!" => ["`~", nil, nil, "2@", "qQ", nil],
|
8
|
+
"\"" => [";:", "[{", "]}", nil, nil, "/?"],
|
9
|
+
"#" => ["2@", nil, nil, "4$", "eE", "wW"],
|
10
|
+
"$" => ["3#", nil, nil, "5%", "rR", "eE"],
|
11
|
+
"%" => ["4$", nil, nil, "6^", "tT", "rR"],
|
12
|
+
"&" => ["6^", nil, nil, "8*", "uU", "yY"],
|
13
|
+
"'" => [";:", "[{", "]}", nil, nil, "/?"],
|
14
|
+
"(" => ["8*", nil, nil, "0)", "oO", "iI"],
|
15
|
+
")" => ["9(", nil, nil, "-_", "pP", "oO"],
|
16
|
+
"*" => ["7&", nil, nil, "9(", "iI", "uU"],
|
17
|
+
"+" => ["-_", nil, nil, nil, "]}", "[{"],
|
18
|
+
"," => ["mM", "kK", "lL", ".>", nil, nil],
|
19
|
+
"-" => ["0)", nil, nil, "=+", "[{", "pP"],
|
20
|
+
"." => [",<", "lL", ";:", "/?", nil, nil],
|
21
|
+
"/" => [".>", ";:", "'\"", nil, nil, nil],
|
22
|
+
"0" => ["9(", nil, nil, "-_", "pP", "oO"],
|
23
|
+
"1" => ["`~", nil, nil, "2@", "qQ", nil],
|
24
|
+
"2" => ["1!", nil, nil, "3#", "wW", "qQ"],
|
25
|
+
"3" => ["2@", nil, nil, "4$", "eE", "wW"],
|
26
|
+
"4" => ["3#", nil, nil, "5%", "rR", "eE"],
|
27
|
+
"5" => ["4$", nil, nil, "6^", "tT", "rR"],
|
28
|
+
"6" => ["5%", nil, nil, "7&", "yY", "tT"],
|
29
|
+
"7" => ["6^", nil, nil, "8*", "uU", "yY"],
|
30
|
+
"8" => ["7&", nil, nil, "9(", "iI", "uU"],
|
31
|
+
"9" => ["8*", nil, nil, "0)", "oO", "iI"],
|
32
|
+
":" => ["lL", "pP", "[{", "'\"", "/?", ".>"],
|
33
|
+
";" => ["lL", "pP", "[{", "'\"", "/?", ".>"],
|
34
|
+
"<" => ["mM", "kK", "lL", ".>", nil, nil],
|
35
|
+
"=" => ["-_", nil, nil, nil, "]}", "[{"],
|
36
|
+
">" => [",<", "lL", ";:", "/?", nil, nil],
|
37
|
+
"?" => [".>", ";:", "'\"", nil, nil, nil],
|
38
|
+
"@" => ["1!", nil, nil, "3#", "wW", "qQ"],
|
39
|
+
"A" => [ nil, "qQ", "wW", "sS", "zZ", nil],
|
40
|
+
"B" => ["vV", "gG", "hH", "nN", nil, nil],
|
41
|
+
"C" => ["xX", "dD", "fF", "vV", nil, nil],
|
42
|
+
"D" => ["sS", "eE", "rR", "fF", "cC", "xX"],
|
43
|
+
"E" => ["wW", "3#", "4$", "rR", "dD", "sS"],
|
44
|
+
"F" => ["dD", "rR", "tT", "gG", "vV", "cC"],
|
45
|
+
"G" => ["fF", "tT", "yY", "hH", "bB", "vV"],
|
46
|
+
"H" => ["gG", "yY", "uU", "jJ", "nN", "bB"],
|
47
|
+
"I" => ["uU", "8*", "9(", "oO", "kK", "jJ"],
|
48
|
+
"J" => ["hH", "uU", "iI", "kK", "mM", "nN"],
|
49
|
+
"K" => ["jJ", "iI", "oO", "lL", ",<", "mM"],
|
50
|
+
"L" => ["kK", "oO", "pP", ";:", ".>", ",<"],
|
51
|
+
"M" => ["nN", "jJ", "kK", ",<", nil, nil],
|
52
|
+
"N" => ["bB", "hH", "jJ", "mM", nil, nil],
|
53
|
+
"O" => ["iI", "9(", "0)", "pP", "lL", "kK"],
|
54
|
+
"P" => ["oO", "0)", "-_", "[{", ";:", "lL"],
|
55
|
+
"Q" => [ nil, "1!", "2@", "wW", "aA", nil],
|
56
|
+
"R" => ["eE", "4$", "5%", "tT", "fF", "dD"],
|
57
|
+
"S" => ["aA", "wW", "eE", "dD", "xX", "zZ"],
|
58
|
+
"T" => ["rR", "5%", "6^", "yY", "gG", "fF"],
|
59
|
+
"U" => ["yY", "7&", "8*", "iI", "jJ", "hH"],
|
60
|
+
"V" => ["cC", "fF", "gG", "bB", nil, nil],
|
61
|
+
"W" => ["qQ", "2@", "3#", "eE", "sS", "aA"],
|
62
|
+
"X" => ["zZ", "sS", "dD", "cC", nil, nil],
|
63
|
+
"Y" => ["tT", "6^", "7&", "uU", "hH", "gG"],
|
64
|
+
"Z" => [ nil, "aA", "sS", "xX", nil, nil],
|
65
|
+
"[" => ["pP", "-_", "=+", "]}", "'\"", ";:"],
|
66
|
+
"\\" => ["]}", nil, nil, nil, nil, nil],
|
67
|
+
"]" => ["[{", "=+", nil, "\\|", nil, "'\""],
|
68
|
+
"^" => ["5%", nil, nil, "7&", "yY", "tT"],
|
69
|
+
"_" => ["0)", nil, nil, "=+", "[{", "pP"],
|
70
|
+
"`" => [ nil, nil, nil, "1!", nil, nil],
|
71
|
+
"a" => [ nil, "qQ", "wW", "sS", "zZ", nil],
|
72
|
+
"b" => ["vV", "gG", "hH", "nN", nil, nil],
|
73
|
+
"c" => ["xX", "dD", "fF", "vV", nil, nil],
|
74
|
+
"d" => ["sS", "eE", "rR", "fF", "cC", "xX"],
|
75
|
+
"e" => ["wW", "3#", "4$", "rR", "dD", "sS"],
|
76
|
+
"f" => ["dD", "rR", "tT", "gG", "vV", "cC"],
|
77
|
+
"g" => ["fF", "tT", "yY", "hH", "bB", "vV"],
|
78
|
+
"h" => ["gG", "yY", "uU", "jJ", "nN", "bB"],
|
79
|
+
"i" => ["uU", "8*", "9(", "oO", "kK", "jJ"],
|
80
|
+
"j" => ["hH", "uU", "iI", "kK", "mM", "nN"],
|
81
|
+
"k" => ["jJ", "iI", "oO", "lL", ",<", "mM"],
|
82
|
+
"l" => ["kK", "oO", "pP", ";:", ".>", ",<"],
|
83
|
+
"m" => ["nN", "jJ", "kK", ",<", nil, nil],
|
84
|
+
"n" => ["bB", "hH", "jJ", "mM", nil, nil],
|
85
|
+
"o" => ["iI", "9(", "0)", "pP", "lL", "kK"],
|
86
|
+
"p" => ["oO", "0)", "-_", "[{", ";:", "lL"],
|
87
|
+
"q" => [ nil, "1!", "2@", "wW", "aA", nil],
|
88
|
+
"r" => ["eE", "4$", "5%", "tT", "fF", "dD"],
|
89
|
+
"s" => ["aA", "wW", "eE", "dD", "xX", "zZ"],
|
90
|
+
"t" => ["rR", "5%", "6^", "yY", "gG", "fF"],
|
91
|
+
"u" => ["yY", "7&", "8*", "iI", "jJ", "hH"],
|
92
|
+
"v" => ["cC", "fF", "gG", "bB", nil, nil],
|
93
|
+
"w" => ["qQ", "2@", "3#", "eE", "sS", "aA"],
|
94
|
+
"x" => ["zZ", "sS", "dD", "cC", nil, nil],
|
95
|
+
"y" => ["tT", "6^", "7&", "uU", "hH", "gG"],
|
96
|
+
"z" => [ nil, "aA", "sS", "xX", nil, nil],
|
97
|
+
"{" => ["pP", "-_", "=+", "]}", "'\"", ";:"],
|
98
|
+
"|" => ["]}", nil, nil, nil, nil, nil],
|
99
|
+
"}" => ["[{", "=+", nil, "\\|", nil, "'\""],
|
100
|
+
"~" => [ nil, nil, nil, "1!", nil, nil]
|
101
101
|
},
|
102
102
|
dvorak: {
|
103
|
-
"!"
|
104
|
-
"\""
|
105
|
-
"#"
|
106
|
-
"$"
|
107
|
-
"%"
|
108
|
-
"&"
|
109
|
-
"'"
|
110
|
-
"("
|
111
|
-
")"
|
112
|
-
"*"
|
113
|
-
"+"
|
114
|
-
","
|
115
|
-
"-"
|
116
|
-
"."
|
117
|
-
"/"
|
118
|
-
"0"
|
119
|
-
"1"
|
120
|
-
"2"
|
121
|
-
"3"
|
122
|
-
"4"
|
123
|
-
"5"
|
124
|
-
"6"
|
125
|
-
"7"
|
126
|
-
"8"
|
127
|
-
"9"
|
128
|
-
":"
|
129
|
-
";"
|
130
|
-
"<"
|
131
|
-
"="
|
132
|
-
">"
|
133
|
-
"?"
|
134
|
-
"@"
|
135
|
-
"A"
|
136
|
-
"B"
|
137
|
-
"C"
|
138
|
-
"D"
|
139
|
-
"E"
|
140
|
-
"F"
|
141
|
-
"G"
|
142
|
-
"H"
|
143
|
-
"I"
|
144
|
-
"J"
|
145
|
-
"K"
|
146
|
-
"L"
|
147
|
-
"M"
|
148
|
-
"N"
|
149
|
-
"O"
|
150
|
-
"P"
|
151
|
-
"Q"
|
152
|
-
"R"
|
153
|
-
"S"
|
154
|
-
"T"
|
155
|
-
"U"
|
156
|
-
"V"
|
157
|
-
"W"
|
158
|
-
"X"
|
159
|
-
"Y"
|
160
|
-
"Z"
|
161
|
-
"["
|
162
|
-
"\\"
|
163
|
-
"]"
|
164
|
-
"^"
|
165
|
-
"_"
|
166
|
-
"`"
|
167
|
-
"a"
|
168
|
-
"b"
|
169
|
-
"c"
|
170
|
-
"d"
|
171
|
-
"e"
|
172
|
-
"f"
|
173
|
-
"g"
|
174
|
-
"h"
|
175
|
-
"i"
|
176
|
-
"j"
|
177
|
-
"k"
|
178
|
-
"l"
|
179
|
-
"m"
|
180
|
-
"n"
|
181
|
-
"o"
|
182
|
-
"p"
|
183
|
-
"q"
|
184
|
-
"r"
|
185
|
-
"s"
|
186
|
-
"t"
|
187
|
-
"u"
|
188
|
-
"v"
|
189
|
-
"w"
|
190
|
-
"x"
|
191
|
-
"y"
|
192
|
-
"z"
|
193
|
-
"{"
|
194
|
-
"|"
|
195
|
-
"}"
|
196
|
-
"~"
|
103
|
+
"!" => ["`~", nil, nil, "2@", "'\"", nil],
|
104
|
+
"\"" => [ nil, "1!", "2@", ",<", "aA", nil],
|
105
|
+
"#" => ["2@", nil, nil, "4$", ".>", ",<"],
|
106
|
+
"$" => ["3#", nil, nil, "5%", "pP", ".>"],
|
107
|
+
"%" => ["4$", nil, nil, "6^", "yY", "pP"],
|
108
|
+
"&" => ["6^", nil, nil, "8*", "gG", "fF"],
|
109
|
+
"'" => [ nil, "1!", "2@", ",<", "aA", nil],
|
110
|
+
"(" => ["8*", nil, nil, "0)", "rR", "cC"],
|
111
|
+
")" => ["9(", nil, nil, "[{", "lL", "rR"],
|
112
|
+
"*" => ["7&", nil, nil, "9(", "cC", "gG"],
|
113
|
+
"+" => ["/?", "]}", nil, "\\|", nil, "-_"],
|
114
|
+
"," => ["'\"", "2@", "3#", ".>", "oO", "aA"],
|
115
|
+
"-" => ["sS", "/?", "=+", nil, nil, "zZ"],
|
116
|
+
"." => [",<", "3#", "4$", "pP", "eE", "oO"],
|
117
|
+
"/" => ["lL", "[{", "]}", "=+", "-_", "sS"],
|
118
|
+
"0" => ["9(", nil, nil, "[{", "lL", "rR"],
|
119
|
+
"1" => ["`~", nil, nil, "2@", "'\"", nil],
|
120
|
+
"2" => ["1!", nil, nil, "3#", ",<", "'\""],
|
121
|
+
"3" => ["2@", nil, nil, "4$", ".>", ",<"],
|
122
|
+
"4" => ["3#", nil, nil, "5%", "pP", ".>"],
|
123
|
+
"5" => ["4$", nil, nil, "6^", "yY", "pP"],
|
124
|
+
"6" => ["5%", nil, nil, "7&", "fF", "yY"],
|
125
|
+
"7" => ["6^", nil, nil, "8*", "gG", "fF"],
|
126
|
+
"8" => ["7&", nil, nil, "9(", "cC", "gG"],
|
127
|
+
"9" => ["8*", nil, nil, "0)", "rR", "cC"],
|
128
|
+
":" => [ nil, "aA", "oO", "qQ", nil, nil],
|
129
|
+
";" => [ nil, "aA", "oO", "qQ", nil, nil],
|
130
|
+
"<" => ["'\"", "2@", "3#", ".>", "oO", "aA"],
|
131
|
+
"=" => ["/?", "]}", nil, "\\|", nil, "-_"],
|
132
|
+
">" => [",<", "3#", "4$", "pP", "eE", "oO"],
|
133
|
+
"?" => ["lL", "[{", "]}", "=+", "-_", "sS"],
|
134
|
+
"@" => ["1!", nil, nil, "3#", ",<", "'\""],
|
135
|
+
"A" => [ nil, "'\"", ",<", "oO", ";:", nil],
|
136
|
+
"B" => ["xX", "dD", "hH", "mM", nil, nil],
|
137
|
+
"C" => ["gG", "8*", "9(", "rR", "tT", "hH"],
|
138
|
+
"D" => ["iI", "fF", "gG", "hH", "bB", "xX"],
|
139
|
+
"E" => ["oO", ".>", "pP", "uU", "jJ", "qQ"],
|
140
|
+
"F" => ["yY", "6^", "7&", "gG", "dD", "iI"],
|
141
|
+
"G" => ["fF", "7&", "8*", "cC", "hH", "dD"],
|
142
|
+
"H" => ["dD", "gG", "cC", "tT", "mM", "bB"],
|
143
|
+
"I" => ["uU", "yY", "fF", "dD", "xX", "kK"],
|
144
|
+
"J" => ["qQ", "eE", "uU", "kK", nil, nil],
|
145
|
+
"K" => ["jJ", "uU", "iI", "xX", nil, nil],
|
146
|
+
"L" => ["rR", "0)", "[{", "/?", "sS", "nN"],
|
147
|
+
"M" => ["bB", "hH", "tT", "wW", nil, nil],
|
148
|
+
"N" => ["tT", "rR", "lL", "sS", "vV", "wW"],
|
149
|
+
"O" => ["aA", ",<", ".>", "eE", "qQ", ";:"],
|
150
|
+
"P" => [".>", "4$", "5%", "yY", "uU", "eE"],
|
151
|
+
"Q" => [";:", "oO", "eE", "jJ", nil, nil],
|
152
|
+
"R" => ["cC", "9(", "0)", "lL", "nN", "tT"],
|
153
|
+
"S" => ["nN", "lL", "/?", "-_", "zZ", "vV"],
|
154
|
+
"T" => ["hH", "cC", "rR", "nN", "wW", "mM"],
|
155
|
+
"U" => ["eE", "pP", "yY", "iI", "kK", "jJ"],
|
156
|
+
"V" => ["wW", "nN", "sS", "zZ", nil, nil],
|
157
|
+
"W" => ["mM", "tT", "nN", "vV", nil, nil],
|
158
|
+
"X" => ["kK", "iI", "dD", "bB", nil, nil],
|
159
|
+
"Y" => ["pP", "5%", "6^", "fF", "iI", "uU"],
|
160
|
+
"Z" => ["vV", "sS", "-_", nil, nil, nil],
|
161
|
+
"[" => ["0)", nil, nil, "]}", "/?", "lL"],
|
162
|
+
"\\" => ["=+", nil, nil, nil, nil, nil],
|
163
|
+
"]" => ["[{", nil, nil, nil, "=+", "/?"],
|
164
|
+
"^" => ["5%", nil, nil, "7&", "fF", "yY"],
|
165
|
+
"_" => ["sS", "/?", "=+", nil, nil, "zZ"],
|
166
|
+
"`" => [ nil, nil, nil, "1!", nil, nil],
|
167
|
+
"a" => [ nil, "'\"", ",<", "oO", ";:", nil],
|
168
|
+
"b" => ["xX", "dD", "hH", "mM", nil, nil],
|
169
|
+
"c" => ["gG", "8*", "9(", "rR", "tT", "hH"],
|
170
|
+
"d" => ["iI", "fF", "gG", "hH", "bB", "xX"],
|
171
|
+
"e" => ["oO", ".>", "pP", "uU", "jJ", "qQ"],
|
172
|
+
"f" => ["yY", "6^", "7&", "gG", "dD", "iI"],
|
173
|
+
"g" => ["fF", "7&", "8*", "cC", "hH", "dD"],
|
174
|
+
"h" => ["dD", "gG", "cC", "tT", "mM", "bB"],
|
175
|
+
"i" => ["uU", "yY", "fF", "dD", "xX", "kK"],
|
176
|
+
"j" => ["qQ", "eE", "uU", "kK", nil, nil],
|
177
|
+
"k" => ["jJ", "uU", "iI", "xX", nil, nil],
|
178
|
+
"l" => ["rR", "0)", "[{", "/?", "sS", "nN"],
|
179
|
+
"m" => ["bB", "hH", "tT", "wW", nil, nil],
|
180
|
+
"n" => ["tT", "rR", "lL", "sS", "vV", "wW"],
|
181
|
+
"o" => ["aA", ",<", ".>", "eE", "qQ", ";:"],
|
182
|
+
"p" => [".>", "4$", "5%", "yY", "uU", "eE"],
|
183
|
+
"q" => [";:", "oO", "eE", "jJ", nil, nil],
|
184
|
+
"r" => ["cC", "9(", "0)", "lL", "nN", "tT"],
|
185
|
+
"s" => ["nN", "lL", "/?", "-_", "zZ", "vV"],
|
186
|
+
"t" => ["hH", "cC", "rR", "nN", "wW", "mM"],
|
187
|
+
"u" => ["eE", "pP", "yY", "iI", "kK", "jJ"],
|
188
|
+
"v" => ["wW", "nN", "sS", "zZ", nil, nil],
|
189
|
+
"w" => ["mM", "tT", "nN", "vV", nil, nil],
|
190
|
+
"x" => ["kK", "iI", "dD", "bB", nil, nil],
|
191
|
+
"y" => ["pP", "5%", "6^", "fF", "iI", "uU"],
|
192
|
+
"z" => ["vV", "sS", "-_", nil, nil, nil],
|
193
|
+
"{" => ["0)", nil, nil, "]}", "/?", "lL"],
|
194
|
+
"|" => ["=+", nil, nil, nil, nil, nil],
|
195
|
+
"}" => ["[{", nil, nil, nil, "=+", "/?"],
|
196
|
+
"~" => [ nil, nil, nil, "1!", nil, nil]
|
197
197
|
},
|
198
198
|
keypad: {
|
199
|
-
"*"
|
200
|
-
"+"
|
201
|
-
"-"
|
202
|
-
"."
|
203
|
-
"/"
|
204
|
-
"0"
|
205
|
-
"1"
|
206
|
-
"2"
|
207
|
-
"3"
|
208
|
-
"4"
|
209
|
-
"5"
|
210
|
-
"6"
|
211
|
-
"7"
|
212
|
-
"8"
|
213
|
-
"9"
|
199
|
+
"*" => ["/", nil, nil, nil, "-", "+", "9", "8"],
|
200
|
+
"+" => ["9", "*", "-", nil, nil, nil, nil, "6"],
|
201
|
+
"-" => ["*", nil, nil, nil, nil, nil, "+", "9"],
|
202
|
+
"." => ["0", "2", "3", nil, nil, nil, nil, nil],
|
203
|
+
"/" => [ nil, nil, nil, nil, "*", "9", "8", "7"],
|
204
|
+
"0" => [ nil, "1", "2", "3", ".", nil, nil, nil],
|
205
|
+
"1" => [ nil, nil, "4", "5", "2", "0", nil, nil],
|
206
|
+
"2" => ["1", "4", "5", "6", "3", ".", "0", nil],
|
207
|
+
"3" => ["2", "5", "6", nil, nil, nil, ".", "0"],
|
208
|
+
"4" => [ nil, nil, "7", "8", "5", "2", "1", nil],
|
209
|
+
"5" => ["4", "7", "8", "9", "6", "3", "2", "1"],
|
210
|
+
"6" => ["5", "8", "9", "+", nil, nil, "3", "2"],
|
211
|
+
"7" => [ nil, nil, nil, "/", "8", "5", "4", nil],
|
212
|
+
"8" => ["7", nil, "/", "*", "9", "6", "5", "4"],
|
213
|
+
"9" => ["8", "/", "*", "-", "+", nil, "6", "5"]
|
214
214
|
},
|
215
215
|
mac_keypad: {
|
216
|
-
"*"
|
217
|
-
"+"
|
218
|
-
"-"
|
219
|
-
"."
|
220
|
-
"/"
|
221
|
-
"0"
|
222
|
-
"1"
|
223
|
-
"2"
|
224
|
-
"3"
|
225
|
-
"4"
|
226
|
-
"5"
|
227
|
-
"6"
|
228
|
-
"7"
|
229
|
-
"8"
|
230
|
-
"9"
|
231
|
-
"="
|
216
|
+
"*" => ["/", nil, nil, nil, nil, nil, "-", "9"],
|
217
|
+
"+" => ["6", "9", "-", nil, nil, nil, nil, "3"],
|
218
|
+
"-" => ["9", "/", "*", nil, nil, nil, "+", "6"],
|
219
|
+
"." => ["0", "2", "3", nil, nil, nil, nil, nil],
|
220
|
+
"/" => ["=", nil, nil, nil, "*", "-", "9", "8"],
|
221
|
+
"0" => [ nil, "1", "2", "3", ".", nil, nil, nil],
|
222
|
+
"1" => [ nil, nil, "4", "5", "2", "0", nil, nil],
|
223
|
+
"2" => ["1", "4", "5", "6", "3", ".", "0", nil],
|
224
|
+
"3" => ["2", "5", "6", "+", nil, nil, ".", "0"],
|
225
|
+
"4" => [ nil, nil, "7", "8", "5", "2", "1", nil],
|
226
|
+
"5" => ["4", "7", "8", "9", "6", "3", "2", "1"],
|
227
|
+
"6" => ["5", "8", "9", "-", "+", nil, "3", "2"],
|
228
|
+
"7" => [ nil, nil, nil, "=", "8", "5", "4", nil],
|
229
|
+
"8" => ["7", nil, "=", "/", "9", "6", "5", "4"],
|
230
|
+
"9" => ["8", "=", "/", "*", "-", "+", "6", "5"],
|
231
|
+
"=" => [ nil, nil, nil, nil, "/", "9", "8", "7"]
|
232
232
|
}
|
233
233
|
}
|
234
234
|
end
|
data/lib/zxcvbn/matching.rb
CHANGED
@@ -23,21 +23,22 @@ module Zxcvbn
|
|
23
23
|
}
|
24
24
|
|
25
25
|
L33T_TABLE = {
|
26
|
-
a
|
27
|
-
b
|
28
|
-
c
|
29
|
-
e
|
30
|
-
g
|
31
|
-
i
|
32
|
-
l
|
33
|
-
o
|
34
|
-
s
|
35
|
-
t
|
36
|
-
x
|
37
|
-
z
|
26
|
+
"a" => ['4', '@'],
|
27
|
+
"b" => ['8'],
|
28
|
+
"c" => ['(', '{', '[', '<'],
|
29
|
+
"e" => ['3'],
|
30
|
+
"g" => ['6', '9'],
|
31
|
+
"i" => ['1', '!', '|'],
|
32
|
+
"l" => ['1', '|', '7'],
|
33
|
+
"o" => ['0'],
|
34
|
+
"s" => ['$', '5'],
|
35
|
+
"t" => ['+', '7'],
|
36
|
+
"x" => ['%'],
|
37
|
+
"z" => ['2']
|
38
38
|
}
|
39
39
|
|
40
40
|
REGEXEN = {
|
41
|
+
# alpha_lower: /[a-z]/,
|
41
42
|
# recent_year: /19\d\d|200\d|201\d/g
|
42
43
|
recent_year: /19\d\d|200\d|201\d/
|
43
44
|
}
|
@@ -115,20 +116,10 @@ module Zxcvbn
|
|
115
116
|
obj.empty?
|
116
117
|
end
|
117
118
|
|
118
|
-
# extend: function(lst, lst2) {
|
119
|
-
# return lst.push.apply(lst, lst2);
|
120
|
-
# },
|
121
|
-
|
122
119
|
def self.translate(string, chr_map)
|
123
120
|
string.split('').map {|chr| chr_map[chr] || chr}.join("")
|
124
121
|
end
|
125
122
|
|
126
|
-
def self.mod(n, m)
|
127
|
-
# double check the need for this function
|
128
|
-
binding.pry
|
129
|
-
# return ((n % m) + m) % m; # mod impl that works for negative numbers
|
130
|
-
end
|
131
|
-
|
132
123
|
def self.sorted(matches)
|
133
124
|
# sort on i primary, j secondary
|
134
125
|
matches.sort_by{|match| [match[:i], match[:j]] }
|
@@ -164,7 +155,7 @@ module Zxcvbn
|
|
164
155
|
pattern: 'dictionary',
|
165
156
|
i: i,
|
166
157
|
j: j,
|
167
|
-
token:
|
158
|
+
token: password[i..j],
|
168
159
|
matched_word: word,
|
169
160
|
rank: rank,
|
170
161
|
dictionary_name: dictionary_name.to_s,
|
@@ -337,7 +328,7 @@ module Zxcvbn
|
|
337
328
|
j = i + 1
|
338
329
|
last_direction = nil
|
339
330
|
turns = 0
|
340
|
-
if (graph_name ==
|
331
|
+
if (graph_name == :qwerty || graph_name == :dvorak) && SHIFTED_RX.match?(password[i])
|
341
332
|
# initial character is shifted
|
342
333
|
shifted_count = 1
|
343
334
|
else
|
@@ -385,7 +376,7 @@ module Zxcvbn
|
|
385
376
|
i: i,
|
386
377
|
j: j - 1,
|
387
378
|
token: password[i..j],
|
388
|
-
graph: graph_name,
|
379
|
+
graph: graph_name.to_s,
|
389
380
|
turns: turns,
|
390
381
|
shifted_count: shifted_count
|
391
382
|
}
|
@@ -473,6 +464,7 @@ module Zxcvbn
|
|
473
464
|
result = []
|
474
465
|
|
475
466
|
update = -> (i, j, delta) do
|
467
|
+
delta ||= 0
|
476
468
|
if j - i > 1 || (delta).abs == 1
|
477
469
|
if 0 < delta.abs && delta.abs <= MAX_DELTA
|
478
470
|
token = password[i..j]
|
@@ -539,7 +531,7 @@ module Zxcvbn
|
|
539
531
|
token: token,
|
540
532
|
i: rx_match.begin(0),
|
541
533
|
j: rx_match.end(0) - 1,
|
542
|
-
regex_name: name,
|
534
|
+
regex_name: name.to_s,
|
543
535
|
regex_match: rx_match
|
544
536
|
}
|
545
537
|
match_index = rx_match.begin(0) + 1
|
@@ -572,15 +564,17 @@ module Zxcvbn
|
|
572
564
|
# to every possible date match.
|
573
565
|
matches = []
|
574
566
|
maybe_date_no_separator = /^\d{4,8}$/
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
567
|
+
|
568
|
+
# maybe_date_with_separator = %r{
|
569
|
+
# ^
|
570
|
+
# ( \d{1,4} ) # day, month, year
|
571
|
+
# ( [\s/\\_.-] ) # separator
|
572
|
+
# ( \d{1,2} ) # day, month
|
573
|
+
# \2 # same separator
|
574
|
+
# ( \d{1,4} ) # day, month, year
|
575
|
+
# $
|
576
|
+
# }
|
577
|
+
maybe_date_with_separator = /^(\d{1,4})([\s\/\\_.-])(\d{1,2})\2(\d{1,4})$/
|
584
578
|
|
585
579
|
(0..(password.length - 4)).each do |i|
|
586
580
|
(i + 3..i + 7).each do |j|
|
@@ -642,9 +636,9 @@ module Zxcvbn
|
|
642
636
|
i: i,
|
643
637
|
j: j,
|
644
638
|
separator: rx_match[2],
|
645
|
-
year: dmy
|
646
|
-
month: dmy
|
647
|
-
day: dmy
|
639
|
+
year: dmy[:year],
|
640
|
+
month: dmy[:month],
|
641
|
+
day: dmy[:day]
|
648
642
|
}
|
649
643
|
end
|
650
644
|
end
|
@@ -705,8 +699,8 @@ module Zxcvbn
|
|
705
699
|
if dm
|
706
700
|
return {
|
707
701
|
year: y,
|
708
|
-
month: dm
|
709
|
-
day: dm
|
702
|
+
month: dm[:month],
|
703
|
+
day: dm[:day]
|
710
704
|
}
|
711
705
|
else
|
712
706
|
# for a candidate that includes a four-digit year,
|
data/lib/zxcvbn/scoring.rb
CHANGED
@@ -178,7 +178,7 @@ module Zxcvbn
|
|
178
178
|
optimal_match_sequence = []
|
179
179
|
k = n - 1
|
180
180
|
# find the final best sequence length and score
|
181
|
-
l, g = optimal[:g][k].min_by{|candidate_l, candidate_g| candidate_g }
|
181
|
+
l, g = (optimal[:g][k] || []).min_by{|candidate_l, candidate_g| candidate_g || 0 }
|
182
182
|
while k >= 0
|
183
183
|
m = optimal[:m][k][l]
|
184
184
|
optimal_match_sequence.unshift(m)
|
@@ -245,7 +245,7 @@ module Zxcvbn
|
|
245
245
|
date: method(:date_guesses),
|
246
246
|
}
|
247
247
|
guesses = estimation_functions[match[:pattern].to_sym].call(match)
|
248
|
-
match[:guesses] = [guesses, min_guesses].max
|
248
|
+
match[:guesses] = [guesses, min_guesses].max
|
249
249
|
match[:guesses_log10] = Math.log10(match[:guesses])
|
250
250
|
return match[:guesses]
|
251
251
|
end
|
@@ -308,12 +308,12 @@ module Zxcvbn
|
|
308
308
|
digits: 10,
|
309
309
|
symbols: 33
|
310
310
|
}
|
311
|
-
if char_class_bases.has_key? match[:regex_name]
|
312
|
-
return char_class_bases[match[:regex_name]] ** match[:token].length
|
311
|
+
if char_class_bases.has_key? match[:regex_name].to_sym
|
312
|
+
return char_class_bases[match[:regex_name].to_sym] ** match[:token].length
|
313
313
|
elsif match[:regex_name] == 'recent_year'
|
314
314
|
# conservative estimate of year space: num years from REFERENCE_YEAR.
|
315
315
|
# if year is close to REFERENCE_YEAR, estimate a year space of MIN_YEAR_SPACE.
|
316
|
-
year_space =
|
316
|
+
year_space = (match[:regex_match[0]].to_i - REFERENCE_YEAR).abs
|
317
317
|
year_space = [year_space, MIN_YEAR_SPACE].max
|
318
318
|
return year_space
|
319
319
|
end
|
@@ -421,7 +421,7 @@ module Zxcvbn
|
|
421
421
|
chrs = match[:token].downcase.split('')
|
422
422
|
ss = chrs.count{|chr| chr == subbed }
|
423
423
|
uu = chrs.count{|chr| chr == unsubbed }
|
424
|
-
if ss
|
424
|
+
if ss == 0 || uu == 0
|
425
425
|
# for this sub, password is either fully subbed (444) or fully unsubbed (aaa)
|
426
426
|
# treat that as doubling the space (attacker needs to try fully subbed chars in addition to
|
427
427
|
# unsubbed.)
|
data/lib/zxcvbn/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zxcvbn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Santos
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby port of Dropbox's zxcvbn.js
|
14
14
|
email:
|