# File lib/pwqgen/pwqgen.rb, line 44 def initialize @@wordlist_size = @@wordlist.length @@separators = "-_!$&*+=23456789".split(%r/) @@separators_size = @@separators.length @rand = Random.new end
Public: Returns a random generated password string.
length - number of words used to create the passphrase.
Example
generate 2 # => "Loyal8atomic" generate # => "Gate*Abound&hull"
Returns a password string.
# File lib/pwqgen/pwqgen.rb, line 64 def generate(length = 3) output = Array.new for i in 1..length output << @@wordlist[@rand.rand(@@wordlist_size)] output[i-1] = output[i-1].capitalize if @rand.rand(2) output << @@separators[@rand.rand(@@separators_size)] unless i == length end output.join end