os3里面md5加密函数
时间:2008-05-14 来源:dijiaquan
加密:
function osc_rand($min = null, $max = null) {
static $seeded;
if (!isset($seeded)) {
if (version_compare(PHP_VERSION, '4.2', '
$seeded = true;
}
if (is_numeric($min) && is_numeric($max)) {
if ($min >= $max) {
return $min;
} else {
return mt_rand($min, $max);
}
} else {
return mt_rand();
}
}
function osc_encrypt_string($plain) {
$password = '';
for ($i=0; $i
$salt = substr(md5($password), 0, 2);
$password = md5($salt . $plain) . ':' . $salt;
return $password;
}
osc_encrypt_string($password);
解密:
$password为登录时,输入的密码。
$Qcheck->value('customers_password')为数据库里面加密的密码。
if ( (strlen($password) > 0) && (strlen($Qcheck->value('customers_password')) > 0) ) {
stack = explode(':', $Qcheck->value('customers_password'));
if (sizeof($stack) === 2) {
if (md5($stack[1] . $password) == $stack[0]) {
return true;
}
}
}
相关阅读 更多 +