Module: Realistic

Included in:
PhoenixPassword
Defined in:
lib/realistic.rb

Instance Method Summary collapse

Instance Method Details

#check_eight(data) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/realistic.rb', line 81

def check_eight(data)

	if @strictness >= 2
		return false if data[:combination].match(/[0-9]{8}/)
	end

	if @strictness >= 3
		return false if data[:combination].match(/[A-Z]{8}/i)
	end

	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}|
	[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)

	if @strictness >=1
		return false if data[:combination].match(/([a-z]{4}[0-9]{4}|[0-9]{4}[a-z]{4})/i)
	end

	if @own_rules
		return false if user_rules(data)
	end

	return true
end

#check_eleven(data) ⇒ Object



154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/realistic.rb', line 154

def check_eleven(data)

	if @strictness >= 2
		return false if data[:combination].match(/[0-9]{11}/)
	end

	if @strictness >= 3
		return false if data[:combination].match(/[A-Z]{11}/i)
	end

	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}|
	[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})/)

	if @strictness >=1
		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)
	end

	if @own_rules
		return false if user_rules(data)
	end

	return true
end

#check_fifteen(data) ⇒ Object



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/realistic.rb', line 254

def check_fifteen(data)

	if @strictness >= 2
		return false if data[:combination].match(/[0-9]{15}/)
	end

	if @strictness >= 3
		return false if data[:combination].match(/[A-Z]{15}/i)
	end

	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}|
	[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})/)

	if @strictness >=1
		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)
	end

	if @own_rules
		return false if user_rules(data)
	end

	return true

end

#check_five(data) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/realistic.rb', line 10

def check_five(data)

	if @strictness >= 2
		return false if data[:combination].match(/[0-9]{6}/)
	end

	if @strictness >= 3
		return false if data[:combination].match(/[A-Z]{6}/i)
	end

	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})/)

	if @strictness >=1
		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)
	end

	if @own_rules
		return false if user_rules(data)
	end

	return true	
end

#check_fourteen(data) ⇒ Object



228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/realistic.rb', line 228

def check_fourteen(data)
	

	if @strictness >= 2
		return false if data[:combination].match(/[0-9]{14}/)
	end

	if @strictness >= 3
		return false if data[:combination].match(/[A-Z]{14}/i)
	end

	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}|
	[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})/)


	if @strictness >=1
		return false if data[:combination].match(/([a-z]{7}[0-9]{7}|[0-9]{7}[a-z]{7})/i)
	end

	if @own_rules
		return false if user_rules(data)
	end

	return true
end

#check_nine(data) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/realistic.rb', line 105

def check_nine(data)


	if @strictness >= 2
		return false if data[:combination].match(/[0-9]{9}/)
	end

	if @strictness >= 3
		return false if data[:combination].match(/[A-Z]{9}/i)
	end

	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}|
	[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)

	if @strictness >=1
		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)
	end

	if @own_rules
		return false if user_rules(data)
	end

	return true
end

#check_seven(data) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/realistic.rb', line 57

def check_seven(data)
	
	if @strictness >= 3
		return false if data[:combination].match(/[A-Z]{7}/i)
	end
	
	if @strictness >= 2
		return false if data[:combination].match(/[0-9]{7}/)
	end
	
	return false if data[:combination].match(/([a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}|
	[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)

	if @strictness >=1
		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)
	end

	if @own_rules
		return false if user_rules(data)
	end

	return true
end

#check_six(data) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/realistic.rb', line 33

def check_six(data)

	if @strictness >= 2
		return false if data[:combination].match(/[0-9]{6}/)
	end

	if @strictness >= 3
		return false if data[:combination].match(/[A-Z]{6}/i)
	end

	return false if data[:combination].match(/([a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}|
	[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1}[0-9]{1}[a-z]{1})/)

	if @strictness >=1
		return false if data[:combination].match(/^([a-z]{3}[0-9]{3}|[0-9]{3}[a-z]{3})$/i)
	end

	if @own_rules
		return false if user_rules(data)
	end

	return true	
end

#check_ten(data) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/realistic.rb', line 130

def check_ten(data)

	if @strictness >= 2
		return false if data[:combination].match(/[0-9]{10}/)
	end

	if @strictness >= 3
		return false if data[:combination].match(/[A-Z]{10}/i)
	end

	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}|
	[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})/)
	
	if @strictness >=1
		return false if data[:combination].match(/([a-z]{5}[0-9]{5}|[0-9]{5}[a-z]{5})/i)
	end
	
	if @own_rules
		return false if user_rules(data)
	end

	return true
end

#check_thirteen(data) ⇒ Object



204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/realistic.rb', line 204

def check_thirteen(data)

	if @strictness >= 2
		return false if data[:combination].match(/[0-9]{13}/)
	end

	if @strictness >= 3
		return false if data[:combination].match(/[A-Z]{13}/i)
	end

	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}|
	[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})/)

	if @strictness >=1
		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)
	end

	if @own_rules
		return false if user_rules(data)
	end

	return true
end

#check_twelve(data) ⇒ Object



178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/realistic.rb', line 178

def check_twelve(data)


	if @strictness >= 2
		return false if data[:combination].match(/[0-9]{12}/)
	end

	if @strictness >= 3
		return false if data[:combination].match(/[A-Z]{12}/i)
	end

	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}|
	[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})/)

	if @strictness >=1
		return false if data[:combination].match(/([a-z]{6}[0-9]{6}|[0-9]{6}[a-z]{6})/i)
	end

	if @own_rules
		return false if user_rules(data)
	end

	return true
end

#rules_pass?(data) ⇒ Boolean

Returns:

  • (Boolean)


279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/realistic.rb', line 279

def rules_pass?(data)

	if data[:cmb_length] == 5
		return check_five(data)
	elsif data[:cmb_length] == 6
		return check_six(data)
	elsif data[:cmb_length] == 7
		return check_seven(data)
	elsif data[:cmb_length] == 8
		return check_eight(data)
	elsif data[:cmb_length] == 9
		return check_nine(data)
	elsif data[:cmb_length] == 10
		return check_ten(data)
	elsif data[:cmb_length] == 11
		return check_eleven(data)
	elsif data[:cmb_length] == 12
		return check_twelve(data)
	elsif data[:cmb_length] == 13
		return check_thirteen(data)
	elsif data[:cmb_length] == 14
		return check_fourteen(data)
	elsif data[:cmb_length] == 15
		return check_fifteen(data)
	end

	return true
end

#user_rules(data) ⇒ Object



3
4
5
6
7
8
# File 'lib/realistic.rb', line 3

def user_rules(data)
	@own_rules.each do |rule|
		return true if data[:combination].match(rule)
	end
	return false
end