class AdminAuth::Encryptor

Public Instance Methods

compare_passwords?(password, encrypted_password) click to toggle source
# File lib/admin_auth/encryptor.rb, line 9
def compare_passwords?(password, encrypted_password)
  salt = encrypted_salt(encrypted_password)
  hashed_password = encrypted_password(password, salt)

  compare_passwords(hashed_password, encrypted_password)
end
encrypt_password(password) click to toggle source
# File lib/admin_auth/encryptor.rb, line 5
def encrypt_password(password)
  create_encrypted_password(password)
end

Private Instance Methods

compare_passwords(hashed_password, encrypted_password) click to toggle source
# File lib/admin_auth/encryptor.rb, line 30
def compare_passwords(hashed_password, encrypted_password)
  Rack::Utils.secure_compare(hashed_password, encrypted_password)
end
create_encrypted_password(password) click to toggle source
# File lib/admin_auth/encryptor.rb, line 18
def create_encrypted_password(password)
  BCrypt::Password.create(password, cost: 10)
end
encrypted_password(password, salt) click to toggle source
# File lib/admin_auth/encryptor.rb, line 26
def encrypted_password(password, salt)
  BCrypt::Engine.hash_secret(password, salt)
end
encrypted_salt(encrypted_password) click to toggle source
# File lib/admin_auth/encryptor.rb, line 22
def encrypted_salt(encrypted_password)
  BCrypt::Password.new(encrypted_password).salt
end