>5) + $b); $z += (($y<<4) + $c) ^ ($y + $sum) ^ (($y>>5) + $d); } $tempInt[0]=$y; $tempInt[1]=$z; return EncryptUtil::integerToBytes($tempInt, 0); } public static function decrypt($bytes){ } public static function bytesToInteger($bytes, $position) { $val = 0; $val = $bytes[$position + 3] & 0xff; $val <<= 8; $val |= $bytes[$position + 2] & 0xff; $val <<= 8; $val |= $bytes[$position + 1] & 0xff; $val <<= 8; $val |= $bytes[$position] & 0xff; return $val; } public static function integerToBytes($val) { $byt = array(); $byt[0] = ($val & 0xff); $byt[1] = ($val >> 8 & 0xff); $byt[2] = ($val >> 16 & 0xff); $byt[3] = ($val >> 24 & 0xff); return $byt; } public static function getBytes($string) { $bytes = array(); for ($i = 0; $i < strlen($string); $i++) { $bytes[] = ord($string[$i]); } return $bytes; } public static function getTeaKey($key) { $ints = array(); $ints[0] = intval(substr($key, 0, 8),16); $ints[1] = intval(substr($key, 8, 8),16); $ints[2] = intval(substr($key, 16, 8),16); $ints[3] = intval(substr($key, 24, 8),16); return $ints; } public static function strToHex($string)//字符串转十六进制 { $hex = ""; for ($i = 0; $i < strlen($string); $i++) $hex .= dechex(ord($string[$i])); $hex = strtoupper($hex); return $hex; } } print_r(EncryptUtil::getTeaKey("12345678123456781234567812345678")); print_r(ord('a'));