fix my reverse
This commit is contained in:
parent
1558625e0a
commit
abff68b382
3 changed files with 12 additions and 3 deletions
lib
11
lib/MPW.rb
11
lib/MPW.rb
|
@ -360,9 +360,18 @@ class MPW
|
|||
def self.generatePassword(length=8)
|
||||
if length.to_i <= 0
|
||||
length = 8
|
||||
else
|
||||
length = length.to_i
|
||||
end
|
||||
|
||||
return ([*('A'..'Z'),*('a'..'z'),*('0'..'9')]).sample(length.to_i).join
|
||||
result = ''
|
||||
while length > 62 do
|
||||
result << ([*('A'..'Z'),*('a'..'z'),*('0'..'9')]).sample(62).join
|
||||
length -= 62
|
||||
end
|
||||
result << ([*('A'..'Z'),*('a'..'z'),*('0'..'9')]).sample(length).join
|
||||
|
||||
return result
|
||||
#return ([*('A'..'Z'),*('a'..'z'),*('0'..'9')]-%w(0 1 I O l i o)).sample(length).join
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue