comparison bin/pwgen @ 651:bdc9eddf3743

[pwgen] rewrite in shell script
author nanaya <me@nanaya.pro>
date Wed, 25 Nov 2020 01:43:25 +0900
parents fea77cdcdb09
children
comparison
equal deleted inserted replaced
650:6ca63cec0879 651:bdc9eddf3743
1 #!/usr/bin/env ruby 1 #!/bin/sh
2 2
3 require 'securerandom' 3 set -e
4 set -u
4 5
5 length = ARGV[0].to_i 6 _length="${1:-12}"
6 length = 12 if length <= 0 7
7 5.times do |n| 8 for i in 1 2 3 4 5; do
8 puts "#{n}: #{SecureRandom.urlsafe_base64(length).slice(0, length)}" 9 printf "%s: " "$i"
9 end 10 openssl rand -base64 "$_length" | tr '/+' '-_' | cut -c "1-$_length"
11 done