class TripPhrase::PhraseGenerator

Constants

TEMPLATES

Attributes

password[R]
salt[R]

Public Class Methods

new(salt, password) click to toggle source
# File lib/trip_phrase/phrase_generator.rb, line 15
def initialize(salt, password)
  @salt     = salt
  @password = password
end

Public Instance Methods

next_key() click to toggle source
# File lib/trip_phrase/phrase_generator.rb, line 20
def next_key
  @key ||= Digest::MD5.hexdigest(salt + password)
  @key = @key[-1] + @key[0..-2]
  @key.hex
end
phrase() click to toggle source
# File lib/trip_phrase/phrase_generator.rb, line 30
def phrase
  template.map { |type|
    send(type)[next_key]
  }.join(' ')
end
template() click to toggle source
# File lib/trip_phrase/phrase_generator.rb, line 26
def template
  TEMPLATES[next_key % 4]
end