rhymix/classes/security/Password.class.php
Kijin Sung dfa1e93c79 Remove unnecessary header and footer from class files
- 아래에 이미 author 언급이 있으므로 중복되는 저작권 표기는 제거
- 클래스 하단에 불필요한 end of file 표시 제거 (파일 하나에 클래스 하나씩이므로
  파일이 중간에 끊겼다면 클래스가 닫히지 않아 쉽게 알 수 있음)
2023-01-30 23:52:23 +09:00

92 lines
2.3 KiB
PHP

<?php
class Password
{
public static function registerCustomAlgorithm($name, $regexp, $callback)
{
Rhymix\Framework\Password::addAlgorithm($name, $regexp, $callback);
}
public static function getSupportedAlgorithms()
{
return Rhymix\Framework\Password::getSupportedAlgorithms();
}
public static function getBestAlgorithm()
{
return Rhymix\Framework\Password::getBestSupportedAlgorithm();
}
public static function getCurrentlySelectedAlgorithm()
{
return Rhymix\Framework\Password::getDefaultAlgorithm();
}
public static function getWorkFactor()
{
return Rhymix\Framework\Password::getWorkFactor();
}
public static function createHash($password, $algorithm = null)
{
return Rhymix\Framework\Password::hashPassword($password, $algorithm);
}
public static function checkPassword($password, $hash, $algorithm = null)
{
return Rhymix\Framework\Password::checkPassword($password, $hash, $algorithm);
}
public static function checkAlgorithm($hash)
{
$algos = Rhymix\Framework\Password::checkAlgorithm($hash);
return count($algos) ? $algos[0] : false;
}
public static function checkWorkFactor($hash)
{
return Rhymix\Framework\Password::checkWorkFactor($hash);
}
public static function createSecureSalt($length, $format = 'hex')
{
return Rhymix\Framework\Security::getRandom($length, $format);
}
public static function createTemporaryPassword($length = 16)
{
return Rhymix\Framework\Password::getRandomPassword($length);
}
public static function createSignature($string)
{
return Rhymix\Framework\Security::createSignature($string);
}
public static function checkSignature($string, $signature)
{
return Rhymix\Framework\Security::verifySignature($string, $signature);
}
public static function getSecretKey()
{
return config('crypto.authentication_key');
}
public static function pbkdf2($password, $salt, $algorithm = 'sha256', $iterations = 8192, $length = 24)
{
$hash = Rhymix\Framework\Security::pbkdf2($password, $salt, $algorithm, $iterations, $length);
$hash = explode(':', $hash);
return base64_decode($hash[3]);
}
public static function bcrypt($password, $salt = null)
{
return Rhymix\Framework\Security::bcrypt($password, $salt);
}
public static function strcmpConstantTime($a, $b)
{
return Rhymix\Framework\Security::compareStrings($a, $b);
}
}