changeset 495:fea77cdcdb09

Size-customizable pwgen.
author edogawaconan <me@myconan.net>
date Fri, 20 Dec 2013 20:17:00 +0900
parents 229acf12b960
children 6bdf99bfbe97
files bin/pwgen
diffstat 1 files changed, 3 insertions(+), 1 deletions(-) [+]
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