I am trying to add a $strength variable as well. 1 would be
(“a”…“z”).to_a 2 would be (“a”…“z”).to_a + (“A”…“Z”).to_a and 3
would be the current one. I tryed splitting it out with an IF…ELSIF
like:
if $strength == 1 then
chars = (“a”…“z”).to_a
elsif $strength == 2 then
chars = (“a”…“z”).to_a + (“A”…“Z”).to_a
elsif $strength == 3 then
chars = (“a”…“z”).to_a + (“A”…“Z”).to_a + (0…9).to_a
Doesn’t seem to like that…I am also gonna do a GetoptLong to take
command
line parameters to override the defaults but I need to get past the
split out.
Also how would I add symbols (i.e. ~ ! @ # $ % ^ & * ( ) + = )?
(1..pwlen).collect{|x| chars[rand(chars.length)].chr }
# Since chars has changed from an array to string, in my above
version.
end
puts generate_password
I am trying to add a $strength variable as well. 1 would be
(“a”…“z”).to_a 2 would be (“a”…“z”).to_a + (“A”…“Z”).to_a and 3
would be the current one. I tryed splitting it out with an IF…ELSIF
like:
HTH
···
–
([ Kent Dahl ]/)_ ~[ http://www.stud.ntnu.no/~kentda/ ]/~
))_student/(( _d L b_/ NTNU - graduate engineering - 5. year )
( __õ|õ// ) )Industrial economics and technological management(
_/ö____/ (_engineering.discipline=Computer::Technology)