PHP初记|xxtea类
程序员文章站
2022-06-03 09:08:31
...
PHP小记|xxtea类
xxtea可逆加密算法PHP实现:
?
Class Xxtea { public function encrypt($s, $key) { return base64_encode(self :: xxtea_encrypt($s, $key)); } public function decrypt($e, $key) { return self :: xxtea_decrypt(base64_decode($e), $key); } private function long2str($v, $w) { $len = count($v); $n = ($len -1) $n)) return false; $n = $m; } $s = array (); for ($i = 0; $i = 2147483648) $n -= 4294967296; while ($n > 2 & 3; for ($p = 0; $p > 5 & 0x07ffffff) ^ $y > 3 & 0x1fffffff) ^ $z > 5 & 0x07ffffff) ^ $y > 3 & 0x1fffffff) ^ $z > 2 & 3; for ($p = $n; $p > 0; $p--) { $z = $v[$p -1]; $mx = self :: int32((($z >> 5 & 0x07ffffff) ^ $y > 3 & 0x1fffffff) ^ $z > 5 & 0x07ffffff) ^ $y > 3 & 0x1fffffff) ^ $z?
使用方法:
加密:
Xxtea::encrypt(明文字符串, 密钥字符串);
解密:
Xxtea::decrypt(密文字符串, 密钥字符串);
?
相关文章
相关视频