28 lines
638 B
PHP
28 lines
638 B
PHP
|
|
<?php
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace MailAccountAdmin\Common;
|
||
|
|
|
||
|
|
class PasswordHelper
|
||
|
|
{
|
||
|
|
public function hashPassword(string $password): string
|
||
|
|
{
|
||
|
|
return password_hash($password, PASSWORD_DEFAULT);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function verifyPassword(string $password, string $hash): bool
|
||
|
|
{
|
||
|
|
return password_verify($password, $hash);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getPasswordHashType(string $passwordHash): string
|
||
|
|
{
|
||
|
|
if ($passwordHash === '') {
|
||
|
|
return 'empty';
|
||
|
|
}
|
||
|
|
|
||
|
|
$passwordHashInfo = password_get_info($passwordHash);
|
||
|
|
return $passwordHashInfo['algoName'] ?? 'unknown';
|
||
|
|
}
|
||
|
|
}
|