Random strings
Posted by root Tue, 19 Aug 2008 13:06:00 GMT
module Kernel
def random_uc(size=16)
Array.new(size){ rand(26)+65 }.pack('C*')
end
def random_lc(size=16)
Array.new(size){ rand(26)+97 }.pack('C*')
end
def random_num(size=16)
Array.new(size){ rand(10) }.join
end
end
random_uc => "HRTWYJBJEZDKYPTJ"
random_lc => "onxkvkezqukspmcx"
random_num => "5862195932579950"