nog hippere versie
This commit is contained in:
parent
fbeddcff5a
commit
81fa1050a0
2 changed files with 102 additions and 0 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
# Geen I L O i l o 0 1
|
# Geen I L O i l o 0 1
|
||||||
|
|
||||||
@chars=( "A" .. "H", "J", "K", "M", "N", "P" .. "Z", "a" .. "h", "j", "k", "m", "n", "p" .. "z", 2 .. 9, qw(! @ $ % ^ & *) );
|
@chars=( "A" .. "H", "J", "K", "M", "N", "P" .. "Z", "a" .. "h", "j", "k", "m", "n", "p" .. "z", 2 .. 9, qw(! @ $ % ^ & *) );
|
||||||
|
|
||||||
foreach ( 1 .. 8 ) {
|
foreach ( 1 .. 8 ) {
|
||||||
$passwd = join("", @chars[ map { rand @chars } ( 1 .. 8 ) ]);
|
$passwd = join("", @chars[ map { rand @chars } ( 1 .. 8 ) ]);
|
||||||
print "$passwd\n";
|
print "$passwd\n";
|
||||||
|
|
|
||||||
101
pwdmake/pwdmake.rb
Executable file
101
pwdmake/pwdmake.rb
Executable file
|
|
@ -0,0 +1,101 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
|
# $Id$
|
||||||
|
# $URL$
|
||||||
|
|
||||||
|
require "getoptlong"
|
||||||
|
|
||||||
|
def parse_options
|
||||||
|
@options = {}
|
||||||
|
begin
|
||||||
|
opts = GetoptLong.new(
|
||||||
|
[ "-c", GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
|
[ "-l", GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
|
[ "-s", GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
|
[ "-h", GetoptLong::NO_ARGUMENT ]
|
||||||
|
)
|
||||||
|
opts.quiet=true
|
||||||
|
opts.each do |opt, arg|
|
||||||
|
@options[opt] = arg
|
||||||
|
end
|
||||||
|
if @options["-h"]
|
||||||
|
usage
|
||||||
|
end
|
||||||
|
rescue GetoptLong::InvalidOption
|
||||||
|
print "#{$!}\n"
|
||||||
|
usage
|
||||||
|
end
|
||||||
|
# default values
|
||||||
|
if @options["-s"].nil?
|
||||||
|
@options["-s"] = "s"
|
||||||
|
end
|
||||||
|
if @options["-l"].nil?
|
||||||
|
@options["-l"] = 8
|
||||||
|
end
|
||||||
|
if @options["-c"].nil?
|
||||||
|
@options["-c"] = 8
|
||||||
|
end
|
||||||
|
return @options
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def usage
|
||||||
|
print <<XXX
|
||||||
|
Usage: pwdmake.rb [-c <count>] [-l <length>] [-h] [-s <s|p|t>]
|
||||||
|
|
||||||
|
-c <count> generate this many passwords (default: 8)
|
||||||
|
-l <length> generate passwords of this length (default: 8)
|
||||||
|
-s <s|p|t> use character set for [S]MS, [P]aper, [T]elephone (default: s)
|
||||||
|
-h this help message
|
||||||
|
XXX
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
|
def random_string(len)
|
||||||
|
rand_set_max = @rand_chars.size
|
||||||
|
rand_max = @rand_chars[0].size
|
||||||
|
ret = ""
|
||||||
|
lastpos = -1
|
||||||
|
pos = -1
|
||||||
|
len.times{
|
||||||
|
while pos == lastpos
|
||||||
|
pos = rand(rand_max)
|
||||||
|
end
|
||||||
|
lastpos = pos
|
||||||
|
char = @rand_chars[rand(rand_set_max)][pos]
|
||||||
|
if @options["-s"] == "s" && char.chr == '*'
|
||||||
|
spec_max = @spec_chars.size
|
||||||
|
char = @spec_chars[rand(spec_max)]
|
||||||
|
end
|
||||||
|
ret << char
|
||||||
|
}
|
||||||
|
ret
|
||||||
|
end
|
||||||
|
|
||||||
|
@rand_chars = Array.new
|
||||||
|
@spec_chars = ""
|
||||||
|
|
||||||
|
parse_options
|
||||||
|
|
||||||
|
case @options["-s"]
|
||||||
|
# SMS Chars. Available with 1 keypress.
|
||||||
|
when "s"
|
||||||
|
@rand_chars = [ "ADGJMPTW*",
|
||||||
|
"adgjmptw*",
|
||||||
|
"23456789*" ]
|
||||||
|
@spec_chars = ",-?!@:;/()"
|
||||||
|
# Paper chars. No l1I, 0O, g9
|
||||||
|
when "p"
|
||||||
|
@rand_chars = [ "ABCDEFGHJKMNPQRSTUVWXYZabcefhjkmnpqrstuvwxyz2345678!@$%^&*" ]
|
||||||
|
# Telephone class. No mn, akh and none of the paper chars stuff.
|
||||||
|
when "t"
|
||||||
|
@rand_chars = [ "BCDEFGJPQRSTUVWXYZbcefjpqrstuvwxyz2345678!@$%^&*" ]
|
||||||
|
else
|
||||||
|
puts "Charater set '#{@options["-s"]}' unknown"
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
|
(1 .. @options["-c"].to_i).each {
|
||||||
|
puts random_string(@options["-l"].to_i)
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue