Skip to content

Instantly share code, notes, and snippets.

@longlostnick
Created September 8, 2015 17:22
Show Gist options
  • Save longlostnick/a68ba0019e55f339d382 to your computer and use it in GitHub Desktop.
Save longlostnick/a68ba0019e55f339d382 to your computer and use it in GitHub Desktop.
Safari like random passwords in ruby
BASE = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
def random_string(length = 3)
length.times.map { BASE[rand(BASE.length)] }.join
end
puts 4.times.map { random_string }.join('-')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment