Module: PasswordUtils

Defined in:
lib/password_utils.rb,
lib/password_utils/version.rb

Overview

PasswordUtils provides functionality for hashing and verifying passwords using bcrypt. It includes methods to hash a password and verify if a given password matches the hash.

Defined Under Namespace

Classes: Error

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.password_hash(password, cost = 12) ⇒ Object

Hashes the password using bcrypt



12
13
14
# File 'lib/password_utils.rb', line 12

def self.password_hash(password, cost = 12)
  BCrypt::Password.create(password, cost: cost)
end

.password_verify(password, password_hash) ⇒ Object

Verifies a password against a hash



17
18
19
# File 'lib/password_utils.rb', line 17

def self.password_verify(password, password_hash)
  BCrypt::Password.new(password_hash) == password
end