phoenix_password 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/realistic.rb ADDED
@@ -0,0 +1,307 @@
1
+ module Realistic
2
+
3
+ def user_rules(data)
4
+ @own_rules.each do |rule|
5
+ return true if data[:combination].match(rule)
6
+ end
7
+ return false
8
+ end
9
+
10
+ def check_five(data)
11
+
12
+ if @strictness >= 2
13
+ return false if data[:combination].match(/[0-9]{6}/)
14
+ end
15
+
16
+ if @strictness >= 3
17
+ return false if data[:combination].match(/[A-Z]{6}/i)
18
+ end
19
+
20
+ return false if data[:combination].match(/([a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}|[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)
21
+
22
+ if @strictness >=1
23
+ return false if data[:combination].match(/^([a-z]{3}[0-9]{2}|[0-9]{3}[a-z]{2}|[0-9]{3}[a-z]{2}|[0-9]{2}[a-z]{3})$/i)
24
+ end
25
+
26
+ if @own_rules
27
+ return false if user_rules(data)
28
+ end
29
+
30
+ return true
31
+ end
32
+
33
+ def check_six(data)
34
+
35
+ if @strictness >= 2
36
+ return false if data[:combination].match(/[0-9]{6}/)
37
+ end
38
+
39
+ if @strictness >= 3
40
+ return false if data[:combination].match(/[A-Z]{6}/i)
41
+ end
42
+
43
+ return false if data[:combination].match(/([a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}|
44
+ [0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)
45
+
46
+ if @strictness >=1
47
+ return false if data[:combination].match(/^([a-z]{3}[0-9]{3}|[0-9]{3}[a-z]{3})$/i)
48
+ end
49
+
50
+ if @own_rules
51
+ return false if user_rules(data)
52
+ end
53
+
54
+ return true
55
+ end
56
+
57
+ def check_seven(data)
58
+
59
+ if @strictness >= 3
60
+ return false if data[:combination].match(/[A-Z]{7}/i)
61
+ end
62
+
63
+ if @strictness >= 2
64
+ return false if data[:combination].match(/[0-9]{7}/)
65
+ end
66
+
67
+ return false if data[:combination].match(/([a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}|
68
+ [0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)
69
+
70
+ if @strictness >=1
71
+ return false if data[:combination].match(/([a-z]{4}[0-9]{3}|[a-z]{3}[0-9]{4}|[0-9]{4}[a-z]{3}|[0-9]{3}[a-z]{4})/i)
72
+ end
73
+
74
+ if @own_rules
75
+ return false if user_rules(data)
76
+ end
77
+
78
+ return true
79
+ end
80
+
81
+ def check_eight(data)
82
+
83
+ if @strictness >= 2
84
+ return false if data[:combination].match(/[0-9]{8}/)
85
+ end
86
+
87
+ if @strictness >= 3
88
+ return false if data[:combination].match(/[A-Z]{8}/i)
89
+ end
90
+
91
+ return false if data[:combination].match(/([a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}|
92
+ [0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)
93
+
94
+ if @strictness >=1
95
+ return false if data[:combination].match(/([a-z]{4}[0-9]{4}|[0-9]{4}[a-z]{4})/i)
96
+ end
97
+
98
+ if @own_rules
99
+ return false if user_rules(data)
100
+ end
101
+
102
+ return true
103
+ end
104
+
105
+ def check_nine(data)
106
+
107
+
108
+ if @strictness >= 2
109
+ return false if data[:combination].match(/[0-9]{9}/)
110
+ end
111
+
112
+ if @strictness >= 3
113
+ return false if data[:combination].match(/[A-Z]{9}/i)
114
+ end
115
+
116
+ return false if data[:combination].match(/([a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}|
117
+ [0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)
118
+
119
+ if @strictness >=1
120
+ return false if data[:combination].match(/([a-z]{5}[0-9]{4}|[a-z]{4}[0-9]{5}|[0-9]{5}[a-z]{4}|[0-9]{4}[a-z]{5})/i)
121
+ end
122
+
123
+ if @own_rules
124
+ return false if user_rules(data)
125
+ end
126
+
127
+ return true
128
+ end
129
+
130
+ def check_ten(data)
131
+
132
+ if @strictness >= 2
133
+ return false if data[:combination].match(/[0-9]{10}/)
134
+ end
135
+
136
+ if @strictness >= 3
137
+ return false if data[:combination].match(/[A-Z]{10}/i)
138
+ end
139
+
140
+ return false if data[:combination].match(/([a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}|
141
+ [0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)
142
+
143
+ if @strictness >=1
144
+ return false if data[:combination].match(/([a-z]{5}[0-9]{5}|[0-9]{5}[a-z]{5})/i)
145
+ end
146
+
147
+ if @own_rules
148
+ return false if user_rules(data)
149
+ end
150
+
151
+ return true
152
+ end
153
+
154
+ def check_eleven(data)
155
+
156
+ if @strictness >= 2
157
+ return false if data[:combination].match(/[0-9]{11}/)
158
+ end
159
+
160
+ if @strictness >= 3
161
+ return false if data[:combination].match(/[A-Z]{11}/i)
162
+ end
163
+
164
+ return false if data[:combination].match(/([a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}|
165
+ [0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)
166
+
167
+ if @strictness >=1
168
+ return false if data[:combination].match(/([a-z]{5}[0-9]{6}|[a-z]{6}[0-9]{5}|[0-9]{5}[a-z]{6}|[0-9]{6}[a-z]{5})/i)
169
+ end
170
+
171
+ if @own_rules
172
+ return false if user_rules(data)
173
+ end
174
+
175
+ return true
176
+ end
177
+
178
+ def check_twelve(data)
179
+
180
+
181
+ if @strictness >= 2
182
+ return false if data[:combination].match(/[0-9]{12}/)
183
+ end
184
+
185
+ if @strictness >= 3
186
+ return false if data[:combination].match(/[A-Z]{12}/i)
187
+ end
188
+
189
+ return false if data[:combination].match(/([a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}|
190
+ [0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)
191
+
192
+ if @strictness >=1
193
+ return false if data[:combination].match(/([a-z]{6}[0-9]{6}|[0-9]{6}[a-z]{6})/i)
194
+ end
195
+
196
+ if @own_rules
197
+ return false if user_rules(data)
198
+ end
199
+
200
+ return true
201
+ end
202
+
203
+
204
+ def check_thirteen(data)
205
+
206
+ if @strictness >= 2
207
+ return false if data[:combination].match(/[0-9]{13}/)
208
+ end
209
+
210
+ if @strictness >= 3
211
+ return false if data[:combination].match(/[A-Z]{13}/i)
212
+ end
213
+
214
+ return false if data[:combination].match(/([a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}|
215
+ [0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)
216
+
217
+ if @strictness >=1
218
+ return false if data[:combination].match(/([a-z]{7}[0-9]{6}|[a-z]{6}[0-9]{7}|[0-9]{7}[a-z]{6}|[0-9]{6}[a-z]{7})/i)
219
+ end
220
+
221
+ if @own_rules
222
+ return false if user_rules(data)
223
+ end
224
+
225
+ return true
226
+ end
227
+
228
+ def check_fourteen(data)
229
+
230
+
231
+ if @strictness >= 2
232
+ return false if data[:combination].match(/[0-9]{14}/)
233
+ end
234
+
235
+ if @strictness >= 3
236
+ return false if data[:combination].match(/[A-Z]{14}/i)
237
+ end
238
+
239
+ return false if data[:combination].match(/([a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}|
240
+ [0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)
241
+
242
+
243
+ if @strictness >=1
244
+ return false if data[:combination].match(/([a-z]{7}[0-9]{7}|[0-9]{7}[a-z]{7})/i)
245
+ end
246
+
247
+ if @own_rules
248
+ return false if user_rules(data)
249
+ end
250
+
251
+ return true
252
+ end
253
+
254
+ def check_fifteen(data)
255
+
256
+ if @strictness >= 2
257
+ return false if data[:combination].match(/[0-9]{15}/)
258
+ end
259
+
260
+ if @strictness >= 3
261
+ return false if data[:combination].match(/[A-Z]{15}/i)
262
+ end
263
+
264
+ return false if data[:combination].match(/([a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}|
265
+ [0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)
266
+
267
+ if @strictness >=1
268
+ return false if data[:combination].match(/([a-z]{7}[0-9]{8}|[a-z]{8}[0-9]{7}|[0-9]{7}[a-z]{8}|[0-9]{8}[a-z]{7})/i)
269
+ end
270
+
271
+ if @own_rules
272
+ return false if user_rules(data)
273
+ end
274
+
275
+ return true
276
+
277
+ end
278
+
279
+ def rules_pass?(data)
280
+
281
+ if data[:cmb_length] == 5
282
+ return check_five(data)
283
+ elsif data[:cmb_length] == 6
284
+ return check_six(data)
285
+ elsif data[:cmb_length] == 7
286
+ return check_seven(data)
287
+ elsif data[:cmb_length] == 8
288
+ return check_eight(data)
289
+ elsif data[:cmb_length] == 9
290
+ return check_nine(data)
291
+ elsif data[:cmb_length] == 10
292
+ return check_ten(data)
293
+ elsif data[:cmb_length] == 11
294
+ return check_eleven(data)
295
+ elsif data[:cmb_length] == 12
296
+ return check_twelve(data)
297
+ elsif data[:cmb_length] == 13
298
+ return check_thirteen(data)
299
+ elsif data[:cmb_length] == 14
300
+ return check_fourteen(data)
301
+ elsif data[:cmb_length] == 15
302
+ return check_fifteen(data)
303
+ end
304
+
305
+ return true
306
+ end
307
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phoenix_password
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spiros Avlonitis
@@ -60,7 +60,17 @@ email:
60
60
  executables: []
61
61
  extensions: []
62
62
  extra_rdoc_files: []
63
- files: []
63
+ files:
64
+ - ".gitignore"
65
+ - ".rspec"
66
+ - CODE_OF_CONDUCT.md
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - lib/phoenix_password.rb
72
+ - lib/phoenix_password/version.rb
73
+ - lib/realistic.rb
64
74
  homepage: https://github.com/spirosavlonitis/phoenix_password
65
75
  licenses:
66
76
  - MIT