Skip to content

Instantly share code, notes, and snippets.

@theHamdiz
Created February 29, 2016 10:49
Show Gist options
  • Save theHamdiz/a9fb3d2d4829b4a0c33a to your computer and use it in GitHub Desktop.
Save theHamdiz/a9fb3d2d4829b4a0c33a to your computer and use it in GitHub Desktop.
Random Password Generator Ruby Module
module RandomPassword
def generate
# create a one big array of seeding data
seed = [('a'..'z'), ('!'..'+'), (1..9), ('A'..'Z')].map { |e| e.to_a }.flatten
# get random 16 characters from this array
original = (0..16).map { seed[rand(seed.length)] }.join
# just to be sure, randomize them once more
original.split('').shuffle.join
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment