Hello --

On Thu, 16 May 2002, Bob X wrote:

> Python has a whrandom or something like that and I would like to create
>    a random password generator at work in Ruby instead.

Here's something that could get you started:

  def generate_password(minlen=5, maxlen=8)
    chars = ['A'..'Z','a'..'z',0..9].map { |a| a.to_a } .flatten
    len = minlen + rand(maxlen-minlen+1)
    (1..len).map { chars[rand(chars.size)] } .join
  end

(It would actually be better to put chars in a constant somewhere,
rather than re-generating the array each time.  And I would not be
surprised if there were not a better way to generate it anyway.)


David

-- 
David Alan Black
home: dblack / candle.superlink.net
work: blackdav / shu.edu
Web:  http://pirate.shu.edu/~blackdav