Skip to content

Commit

Permalink
split passwords by thrid param
Browse files Browse the repository at this point in the history
  • Loading branch information
Andras Horvath committed Apr 14, 2016
1 parent 1fa4968 commit 85665aa
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion password_generator.rb
Expand Up @@ -277,9 +277,25 @@ def get_password_pron(len)
end
puts
else
# how many character groups we want by splitting up the password
splitter = ARGV[2].to_i
# how many passwords we need
c = ARGV[1].to_i
c = 1 if c < 1
# password length
n = ARGV[0].to_i
n = 4 if n < 4
c.times{ puts get_password_pron(n) }

c.times{
p = get_password_pron(n)
if splitter > 0
i = 0
p = p.chars.map{|x|
i += 1
x = x + " " if i % splitter == 0
x
}.join
end
puts p
}
end

0 comments on commit 85665aa

Please sign in to comment.