Module: Argon2Encryptor

Defined in:
lib/kowl/templates/config/initializers/devise_argon2.rb

Instance Method Summary collapse

Instance Method Details

#compare(klass, hashed_password, password) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/kowl/templates/config/initializers/devise_argon2.rb', line 14

def compare(klass, hashed_password, password)
  return false if hashed_password.blank?

  if hashed_password.start_with?('$argon2')
    if klass.pepper.present?
      password = "#{password}#{klass.pepper}"
    end
    ::Argon2::Password.verify_password(password, hashed_password)
  else
    super
  end
end

#digest(klass, password) ⇒ Object



7
8
9
10
11
12
# File 'lib/kowl/templates/config/initializers/devise_argon2.rb', line 7

def digest(klass, password)
  if klass.pepper.present?
    password = "#{password}#{klass.pepper}"
  end
  ::Argon2::Password.create(password)
end