Created
February 29, 2016 10:49
-
-
Save theHamdiz/a9fb3d2d4829b4a0c33a to your computer and use it in GitHub Desktop.
Random Password Generator Ruby Module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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