Skip to content

Instantly share code, notes, and snippets.

@ttanimichi
Created September 13, 2014 08:21
Show Gist options
  • Save ttanimichi/bff15ecf04b4ce458a6b to your computer and use it in GitHub Desktop.
Save ttanimichi/bff15ecf04b4ce458a6b to your computer and use it in GitHub Desktop.
random string generater
class RandomString
CANDIDATES = ['0'..'9', 'a'..'z', 'A'..'Z'].map(&:to_a).flatten
def self.generate(length: 8)
(1..length).map { CANDIDATES.sample }.join
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment