$saltkey = '.$saltkey;
echo '
$stringA = '.$stringA;
echo '
$pos = '.$pos;
echo '
$salt = '.$salt.'
$stype = '.$stype.'
$slen = '.$slen;
echo '
$afterstr = '.$afterstr;
echo '
$startbeginning = '.$startbeginning;
echo '
$beforestr = '.$beforestr;
echo '
$salted = '.$salted;
}
return $salted;
}
function pepper($str, $dbhash, $debug = 0) { // str = string to be checked against DBHASH
global $saltkey;
// Find the original sha1 hash and check it with the new one
$hashA = sha1($str); // new hash to be checked
$pos = substr($dbhash, -2);
$stype = substr($dbhash, -3, 1); // n or b
if ($stype == 'n') {
$slen = 40;
} else {
$slen = 32;
}
$beforesalt = substr($dbhash, 0, $pos);
$aftersaltA = substr($dbhash, ($pos + $slen));
$aftersalt = substr($aftersaltA, 0, -3);
$saltA = substr($dbhash, $pos, ((-strlen($aftersalt)) - 3));
if ($stype == 'n') {
$salt = sha1($saltkey);
} else {
$salt = md5($saltkey);
}
$unsalted = $beforesalt . $aftersalt;
if ($debug == 1) {
echo '
$saltkey = '.$saltkey;
echo '
$str = '.$str;
echo '
$dbhash = '.$dbhash;
echo '
$hashA = '.$hashA;
echo '
$pos = '.$pos;
echo '
$stype = '.$stype;
echo '
$slen = '.$slen;
echo '
$beforesalt = '.$beforesalt;
echo '
$aftersaltA = '.$aftersaltA;
echo '
$aftersalt = '.$aftersalt;
echo '
$saltA = '.$saltA;
echo '
$salt = '.$salt;
echo '
$unsalted = '.$unsalted.'
if = ';
}
if (($hashA == $unsalted) && ($salt == $saltA)) {
if ($debug == 1): echo 'true'; endif;
return true;
} else {
if ($debug == 1): echo 'false'; endif;
return false;
}
}
?>