Skip to content

Instantly share code, notes, and snippets.

@flou
Created June 19, 2015 19:40
Show Gist options
  • Save flou/f8d9485122a2a8c4d094 to your computer and use it in GitHub Desktop.
Save flou/f8d9485122a2a8c4d094 to your computer and use it in GitHub Desktop.
module Password
CHARS = [*('A'..'Z'), *('a'..'z'), *(0..9), '$']
def self.generate(size = 4)
chunks = []
size.times do
chunks << create_chunk
end
chunks.join('-')
end
def self.create_chunk(size = 4)
CHARS.sample(size).join
end
end
puts Password.generate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment