我想使用 mcrypt_decrypt 解密加密的响应,但这不起作用,所以我使用这段代码进行测试,响应应该是“这是一个测试”:
// Encryption Algorithm
// the $shared_key and $init_vector are not real
$cipher_alg = MCRYPT_RIJNDAEL_128;
$shared_key = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
$key = pack("H*", $shared_key);
$init_vector = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF";
$iv = pack("H*", $init_vector);
echo mcrypt_decrypt($cipher_alg, $key, utf8_encode(mcrypt_encrypt(
$cipher_alg, $key, utf8_encode('This is a test'), MCRYPT_MODE_CBC, $iv)), MCRYPT_MODE_CBC, $iv);
回应是:
æ †,?7÷q†Ý³‚¢gTô1ò‚ù’Ü”®mÀ{ëQS
我做错了什么?