From: "Lloyd Linklater" <lloyd / 2live4.com>
>
> I have been trying to generate a random string.

I use:

def gen_random_string(len)
  (0...len).collect{rand(36).to_s(36)}.map{|x| (rand<0.5)?x:x.upcase}.join
end

...for short strings of length 64 or whatever.  For very long strings, the
above may be a bit inefficient.  (To generate a 1_000_000 character
string takes about 2.4 seconds on my system.)


Regards,

Bill