Class: Seraph::PasswordComparator
- Inherits:
-
Object
- Object
- Seraph::PasswordComparator
- Defined in:
- lib/seraph/password_comparator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(encrypted, plaintext) ⇒ PasswordComparator
constructor
A new instance of PasswordComparator.
Constructor Details
#initialize(encrypted, plaintext) ⇒ PasswordComparator
Returns a new instance of PasswordComparator.
19 20 21 22 |
# File 'lib/seraph/password_comparator.rb', line 19 def initialize(encrypted, plaintext) @encrypted = encrypted @plaintext = plaintext end |
Class Method Details
.call(encrypted, plaintext) ⇒ Object
8 9 10 |
# File 'lib/seraph/password_comparator.rb', line 8 def self.call(encrypted, plaintext) new(encrypted, plaintext).call end |
Instance Method Details
#call ⇒ Object
12 13 14 15 16 17 |
# 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 |