filegator/backend/Utils/PasswordHash.php
Milos Stojanovic 261607e1d3 initial commit
2019-06-13 18:52:40 +02:00

34 lines
639 B
PHP

<?php
/*
* This file is part of the FileGator package.
*
* (c) Milos Stojanovic <alcalbg@gmail.com>
*
* For the full copyright and license information, please view the LICENSE file
*/
namespace Filegator\Utils;
/**
* @codeCoverageIgnore
*/
trait PasswordHash
{
public static function hashPassword($value)
{
$hash = password_hash($value, PASSWORD_BCRYPT);
if ($hash === false) {
throw new \Exception('Bcrypt hashing not supported.');
}
return $hash;
}
public static function verifyPassword($value, $hash)
{
return password_verify($value, $hash);
}
}