mirror of
https://github.com/filegator/filegator.git
synced 2025-08-18 07:01:31 +02:00
initial commit
This commit is contained in:
33
backend/Utils/PasswordHash.php
Normal file
33
backend/Utils/PasswordHash.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user