Файл: adultscript-2.0.3-pro/files/libraries/framework/hash.php
Строк: 17
<?php
defined('_VALID') or die('Restricted Access!');
class VHash
{
private static $cfg_cache = array();
public static function encrypt($password)
{
if (!isset(self::$cfg_cache['hash_type'])) {
self::$cfg_cache = VF::cfg('library.auth');
}
$hash_type = self::$cfg_cache['hash_type'];
if ($hash_type == 'md5') {
return md5($password);
} elseif ($hash_type == 'sha') {
return sha1($password);
} elseif ($hash_type == 'blowfish') {
VF::load('phpass.PasswordHash');
$hasher = new PasswordHash(8, FALSE);
return $hasher->HashPassword($password);
} else {
die('Invalid password hash type specified!');
}
}
public static function check($password, $hash)
{
if (!isset(self::$cfg_cache['hash_type'])) {
self::$cfg_cache = VF::cfg('library.auth');
}
$hash_type = self::$cfg_cache['hash_type'];
if ($hash_type == 'md5') {
return md5($password) == $hash;
} elseif ($hash_type == 'sha') {
return sha1($password) == $hash;
} elseif ($hash_type == 'blowfish') {
VF::load('phpass.PasswordHash');
$hasher = new PasswordHash(8, FALSE);
return $hasher->CheckPassword($password, $hash);
} else {
die('Invalid password hash specified!');
}
}
}
?>