Class: Dgen::PassGen
- Inherits:
-
Object
- Object
- Dgen::PassGen
- Defined in:
- lib/dgen/passgen.rb
Overview
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.
Instance Attribute Summary collapse
-
#n_chars ⇒ Object
readonly
Minimum character length of passphrase.
-
#n_words ⇒ Object
readonly
Number of words to use in passphrase.
-
#word_list ⇒ Object
readonly
File containing the list of words to select words from.
Instance Method Summary collapse
-
#batch(n_pass) ⇒ Object
Produces and displays multiple passphrases.
-
#initialize(n_words, n_chars) ⇒ PassGen
constructor
Initializes a PassGen instance.
-
#single ⇒ Object
Produces and displays a single passphrase.
Constructor Details
#initialize(n_words, n_chars) ⇒ PassGen
Initializes a PassGen instance
41 42 43 44 45 46 47 48 49 |
# File 'lib/dgen/passgen.rb', line 41 def initialize(n_words, n_chars) @n_words = n_words @n_chars = n_chars path = File.(File.join(File.dirname(__FILE__), '..', 'assets', 'word-list.txt')) @word_list = File.new(path, 'r') end |
Instance Attribute Details
#n_chars ⇒ Object (readonly)
Minimum character length of passphrase.
35 36 37 |
# File 'lib/dgen/passgen.rb', line 35 def n_chars @n_chars end |
#n_words ⇒ Object (readonly)
Number of words to use in passphrase.
33 34 35 |
# File 'lib/dgen/passgen.rb', line 33 def n_words @n_words end |
#word_list ⇒ Object (readonly)
File containing the list of words to select words from.
37 38 39 |
# File 'lib/dgen/passgen.rb', line 37 def word_list @word_list end |
Instance Method Details
#batch(n_pass) ⇒ Object
Produces and displays multiple passphrases.
59 60 61 62 63 64 65 |
# 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 ⇒ Object
Produces and displays a single passphrase.
53 54 55 |
# File 'lib/dgen/passgen.rb', line 53 def single Dgen::Diceware.make_phrase(@n_words, @n_chars, @word_list) end |