Skip to content

Instantly share code, notes, and snippets.

@ryenski
Created May 20, 2017 17:39
Show Gist options
  • Save ryenski/1cb61d1bd1e596f7a4182b169a059f35 to your computer and use it in GitHub Desktop.
Save ryenski/1cb61d1bd1e596f7a4182b169a059f35 to your computer and use it in GitHub Desktop.
class PronounceablePassword
WORDS = (IO.readlines(File.join File.dirname(__FILE__), 'words.txt')).each { |w| w.chop! }
class << self
def random_pronouncable_password(options={})
options={
:rand_seed => 999
}.update(options)
words = WORDS.dup
[words.delete_at(rand(words.length)), rand(options[:rand_seed]), words[rand(words.length)]].join("-")
end
alias_method :generate_password!, :random_pronouncable_password
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment