lib/posgra/identifier/auto.rb in posgra-0.1.1 vs lib/posgra/identifier/auto.rb in posgra-0.1.2
- old
+ new
@@ -11,10 +11,23 @@
end
private
def mkpasswd(len = 8)
- [*1..9, *'A'..'Z', *'a'..'z'].shuffle.slice(0, len).join
+ sources = [
+ (1..9).to_a,
+ ('A'..'Z').to_a,
+ ('a'..'z').to_a,
+ ].shuffle
+
+ passwd = []
+
+ len.times do |i|
+ src = sources[i % sources.length]
+ passwd << src.shuffle.shift
+ end
+
+ passwd.join
end
def puts_password(user, password)
open_output do |f|
f.puts("#{user},#{password}")