Skip to content

Instantly share code, notes, and snippets.

@kaznum
Created September 27, 2011 08:59
Show Gist options
  • Save kaznum/1244643 to your computer and use it in GitHub Desktop.
Save kaznum/1244643 to your computer and use it in GitHub Desktop.
generate random string
module RandomString
# chars example is ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a
def self.random_of(chars, length=10)
Array.new(length){chars[rand(chars.size)]}.join
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment