本文整理汇总了PHP中long2str函数的典型用法代码示例。如果您正苦于以下问题:PHP long2str函数的具体用法?PHP long2str怎么用?PHP long2str使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了long2str函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: decrypt
function decrypt($str, $key)
{
if ($str == '') {
return '';
}
$v = str2long($str, false);
$k = str2long($key, false);
if (count($k) < 4) {
for ($i = count($k); $i < 4; $i++) {
$k[$i] = 0;
}
}
$n = count($v) - 1;
$z = $v[$n];
$y = $v[0];
$delta = 0x9e3779b9;
$q = floor(6 + 52 / ($n + 1));
$sum = int32($q * $delta);
while ($sum != 0) {
$e = $sum >> 2 & 3;
for ($p = $n; $p > 0; $p--) {
$z = $v[$p - 1];
$mx = int32(($z >> 5 & 0x7ffffff ^ $y << 2) + ($y >> 3 & 0x1fffffff ^ $z << 4)) ^ int32(($sum ^ $y) + ($k[$p & 3 ^ $e] ^ $z));
$y = $v[$p] = int32($v[$p] - $mx);
}
$z = $v[$n];
$mx = int32(($z >> 5 & 0x7ffffff ^ $y << 2) + ($y >> 3 & 0x1fffffff ^ $z << 4)) ^ int32(($sum ^ $y) + ($k[$p & 3 ^ $e] ^ $z));
$y = $v[0] = int32($v[0] - $mx);
$sum = int32($sum - $delta);
}
return long2str($v, true);
}
示例2: TEAdecrypt
function TEAdecrypt($str, $key = EW_RANDOM_KEY)
{
$str = ew_UrlDecode($str);
if ($str == "") {
return "";
}
$v = str2long($str, false);
$k = str2long($key, false);
$cntk = count($k);
if ($cntk < 4) {
for ($i = $cntk; $i < 4; $i++) {
$k[$i] = 0;
}
}
$n = count($v) - 1;
$z = $v[$n];
$y = $v[0];
$delta = 0.0;
$q = floor(6 + 52 / ($n + 1));
$sum = int32($q * $delta);
while ($sum != 0) {
$e = $sum >> 2 & 3;
for ($p = $n; $p > 0; $p--) {
$z = $v[$p - 1];
$mx = int32(($z >> 5 & 0x7ffffff ^ $y << 2) + ($y >> 3 & 0x1fffffff ^ $z << 4)) ^ int32(($sum ^ $y) + ($k[$p & 3 ^ $e] ^ $z));
$y = $v[$p] = int32($v[$p] - $mx);
}
$z = $v[$n];
$mx = int32(($z >> 5 & 0x7ffffff ^ $y << 2) + ($y >> 3 & 0x1fffffff ^ $z << 4)) ^ int32(($sum ^ $y) + ($k[$p & 3 ^ $e] ^ $z));
$y = $v[0] = int32($v[0] - $mx);
$sum = int32($sum - $delta);
}
return long2str($v, true);
}
示例3: decrypt_string
/** Decipher
* @param string binary cipher
* @param string
* @return string plain-text password
*/
function decrypt_string($str, $key)
{
if ($str == "") {
return "";
}
if (!$key) {
return false;
}
$key = array_values(unpack("V*", pack("H*", md5($key))));
$v = str2long($str, false);
$n = count($v) - 1;
$z = $v[$n];
$y = $v[0];
$q = floor(6 + 52 / ($n + 1));
$sum = int32($q * 0x9e3779b9);
while ($sum) {
$e = $sum >> 2 & 3;
for ($p = $n; $p > 0; $p--) {
$z = $v[$p - 1];
$mx = xxtea_mx($z, $y, $sum, $key[$p & 3 ^ $e]);
$y = int32($v[$p] - $mx);
$v[$p] = $y;
}
$z = $v[$n];
$mx = xxtea_mx($z, $y, $sum, $key[$p & 3 ^ $e]);
$y = int32($v[0] - $mx);
$v[0] = $y;
$sum = int32($sum - 0x9e3779b9);
}
return long2str($v, true);
}