diff bin/pwgen @ 495:fea77cdcdb09

Size-customizable pwgen.
author edogawaconan <me@myconan.net>
date Fri, 20 Dec 2013 20:17:00 +0900
parents 8956a404dba6
children bdc9eddf3743
line wrap: on
line diff
--- a/bin/pwgen	Sat Nov 09 17:33:40 2013 +0900
+++ b/bin/pwgen	Fri Dec 20 20:17:00 2013 +0900
@@ -2,6 +2,8 @@
 
 require 'securerandom'
 
+length = ARGV[0].to_i
+length = 12 if length <= 0
 5.times do |n|
-  puts "#{n}: #{SecureRandom.urlsafe_base64(12)}"
+  puts "#{n}: #{SecureRandom.urlsafe_base64(length).slice(0, length)}"
 end