使用下面的PHP函数进行令牌解密后,会在解密的令牌字符串的末尾添加一些%2500
(它们被称为空字节?)。他们来自哪里以及如何避免这种情况?
加密和解密:
$decrKey = "1234567890000000";
$decrIV = "ABCDEFGHIJKLMNOP";
function encryptAES($data,$key,$iv)
{
$encr = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $data, MCRYPT_MODE_CBC, $iv));
return $encr;
}
function decryptAES($data,$key,$iv)
{
$decr= mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $key, base64_decode($data), MCRYPT_MODE_CBC, $iv);
return $decr;
}
解密令牌:
$oauthToken = $_POST["serviceToken"];
// $oauthToken = 123424154-MUOfpNu9abcYIMEDIGAf4zMdefMlm5nI7d6ocCqi
$oauthToken = decryptAES($oauthToken,$decrKey,$decrIV);