bariseser/hashmanager

PHP hash manager for password hashing.

v1.0.1 2019-08-01 06:08 UTC

This package is auto-updated.

Last update: 2024-10-29 05:59:19 UTC


README

Password Hash Manager provides secure Bcrypt, Argon2i (PHP>=7.2) or Argon2id (PHP>=7.3) hashing for storing user passwords or etc.

contributions welcome Latest Stable Version Total Downloads License Build Status

Requirement

  • PHP 7
    • Bcrypt (>= 5.5.0)
    • Argon2i (>=7.2.0))
    • Argon2id (>=7.3.0))
  • Composer

Installation

Password Hash Manager installation is very simple. Open the terminal and run this command

composer require bariseser/password-hash

Usage

You can creates a new password hash using a strong one-way hashing algorithm

<?php
require '../vendor/autoload.php';
use Bariseser\hashmanager;

$hashManager = HashManager::getInstance()->initialize(HashManager::BCRYPT);
$hash = $driver->hash("Your Password");
echo $hash.PHP_EOL;

Verifies that a password matches a hash

<?php
require '../vendor/autoload.php';
use Bariseser\hashmanager;

$hashManager = HashManager::getInstance()->initialize(HashManager::ARGON2I);
if ($driver->validate("Your Password", $hash)) {
    echo "Valid Password" . PHP_EOL;
} else {
    echo "Invalid Password" . PHP_EOL;
}

Get hash info

<?php
require '../vendor/autoload.php';
use Bariseser\hashmanager;

$hashManager = HashManager::getInstance()->initialize(HashManager::ARGON2I);
$hash = $driver->hash("Your Password");
$info = $driver->getInfo($hash);
echo $hash.PHP_EOL;
print_r($info);

Switch Algorithm

<?php 

$driver->setAlgorithm(HashManager::BCRYPT);
$driver->setAlgorithm(HashManager::ARGON2I);
$driver->setAlgorithm(HashManager::ARGON2ID);

Supported algorithm

  • Bcrypt (>=5.5.0)
  • Argon2I (>=7.2.0)
  • Argon2ID (>=7.3.0)

Getting help / Contact

Contributing

1 - Fork the Project

2 - Ensure you have Composer installed (see Composer Download Instructions)

3 - Install Development Dependencies

composer install

4 - Run the Test Suite

vendor/bin/phpunit

5 - Send us a Pull Request