From: Kent Dahl Date: 2002-10-31T02:58:08+09:00 Subject: Re: Please help me modify this... Bob wrote: > > This currently works: > > # define defaults which can be > # overridden from the command prompt > $minlen = 7 > $maxlen = 9 > > # generator function > def generate_password(minlen=$minlen, maxlen=$maxlen) > chars = ("a".."z").to_a + ("A".."Z").to_a + (0..9).to_a chars = [("a".."z").to_a, ("A".."Z").to_a, (0..9).to_a ][0..($strength-1)].join > pwlen = rand(maxlen - minlen) + minlen + 1 > (1..pwlen).to_a.collect {|x| chars[rand(chars.length)] }.join (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___)