class Dgen::PassGen
PassGen
¶ ↑
- Author
-
Dick Davis
- Copyright
-
Copyright 2015-2018 Dick Davis
- License
-
GNU Public License 3
Generates secure diceware passphrases.
The algorithm used to generate passwords is the Diceware
method, developed by Arnold Reinhold.
Attributes
n_chars[R]
Minimum character length of passphrase.
n_words[R]
Number of words to use in passphrase.
word_list[R]
File containing the list of words to select words from.
Public Class Methods
new(n_words, n_chars)
click to toggle source
Initializes a PassGen
instance
# File lib/dgen/passgen.rb, line 41 def initialize(n_words, n_chars) @n_words = n_words @n_chars = n_chars path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'assets', 'word-list.txt')) @word_list = File.new(path, 'r') end
Public Instance Methods
batch(n_pass)
click to toggle source
Produces and displays multiple passphrases.
# File lib/dgen/passgen.rb, line 59 def batch(n_pass) phrases = [] n_pass.times do phrases.push(Dgen::Diceware.make_phrase(@n_words, @n_chars, @word_list)) end phrases end
single()
click to toggle source
Produces and displays a single passphrase.
# File lib/dgen/passgen.rb, line 53 def single Dgen::Diceware.make_phrase(@n_words, @n_chars, @word_list) end