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 <p>?</p> <p>使用方法:</p> <p><strong>加密:</strong></p> <p><strong>Xxtea::encrypt(明文字符串, 密钥字符串);</strong></p> <p><strong>解密:</strong></p> <p><strong>Xxtea::decrypt(密文字符串, 密钥字符串);</strong></p> <p>?</p> <div class="clear"> </div>