fix my reverse

This commit is contained in:
nishiki 2014-01-09 23:16:07 +01:00
parent 1558625e0a
commit abff68b382
3 changed files with 12 additions and 3 deletions

View file

@ -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