From 85665aa44e8d08c2997345d58d35829859016206 Mon Sep 17 00:00:00 2001 From: Andras Horvath Date: Thu, 14 Apr 2016 14:45:54 +0200 Subject: [PATCH] split passwords by thrid param --- password_generator.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/password_generator.rb b/password_generator.rb index 3ee7aec..ba9d75f 100755 --- a/password_generator.rb +++ b/password_generator.rb @@ -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