averay/password-validator

An object-oriented wrapper around the password_hash & password_verify functions.

v1.0.0 2024-02-23 11:48 UTC

This package is auto-updated.

Last update: 2024-04-23 12:06:16 UTC


README

An object-oriented wrapper around the PHP password_hash & password_verify functions, including an interface for abstraction.

Usage

<?php
$passwordValidator = new \Averay\PasswordValidator\PasswordValidator();

$hash = $passwordValidator->hash('secret value');

if ($passwordValidator->verify('secret value', $hash)) {
  echo '✅ Correct';
} else {
  echo '❌ Incorrect';
}

The algorithm may be customised during instantiation:

<?php
$passwordValidator = new \Averay\PasswordValidator\PasswordValidator(
  \PASSWORD_ARGON2I,
  ['memory_cost' => 2 ^ 32, 'time_cost' => 10],
);