I'm trying to create somewhat readable words in ruby containing upper case, lowercase, numbers, and a special character, something like:
FlAshmnger!2
Derfing$23
To create a random string in ruby you can do something like this:
lower = ('a'...'z').to_a
upper = ('A'...'Z').to_a
numbers = (0...9).to_a
specs = %w(! ? * ^ $)
size = 8
charset = [lower, upper, numbers, specs].flatten
(0...size).map { charset[rand(charset.size)] }.join
#<= ?!VVQUjH
#<= ^tsm^Led
Is there a way I could make sure that the random string is somewhat readable? Containing a constant, vowel, etc.. With a special character and at least one number without the use of an external gem?
Creating your password from scratch
Using this gist as a basis :
Output example :
Using pwgen
You could also just install pwgen and use :
and for more complex passwords :
Correct horse battery staple
Following the recommendations of this XKCD comic, you could just pick 4 common words out of a dictionary (e.g.
/usr/share/dict/american-english
).