class Seraph::PasswordComparator

Attributes

encrypted[R]
plaintext[R]

Public Class Methods

call(encrypted, plaintext) click to toggle source
# File lib/seraph/password_comparator.rb, line 8
def self.call(encrypted, plaintext)
  new(encrypted, plaintext).call
end
new(encrypted, plaintext) click to toggle source
# File lib/seraph/password_comparator.rb, line 19
def initialize(encrypted, plaintext)
  @encrypted = encrypted
  @plaintext = plaintext
end

Public Instance Methods

call() click to toggle source
# File lib/seraph/password_comparator.rb, line 12
def call
  bcrypt = BCrypt::Password.new(encrypted)
  peppered_password = String(pepper) == '' ? plaintext : "#{plaintext}:#{pepper}"
  password = BCrypt::Engine.hash_secret(peppered_password, bcrypt.salt)
  Utils.compare(encrypted, password)
end

Private Instance Methods

pepper() click to toggle source
# File lib/seraph/password_comparator.rb, line 28
def pepper
  String(Seraph.configuration.pepper)
end