加密日语文本无法解密

时间:2013-10-21 19:58:59

标签: php encryption character-encoding base64

我想加密和编码日文文本并将其发送给第三方,后者将对其进行解密。

//encryption
 $get_params = '有場'
 $encode_iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
 $encode_iv = mcrypt_create_iv($encode_iv_size,MCRYPT_RAND);
 $get_params = drupal_http_build_query($data2);  
//encode
 $encode_crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, 'b54763051cef08bc', $get_params , MCRYPT_MODE_CBC, $encode_iv);

# prepend the IV for it to be available for decryption
 $encode_crypttext =  $encode_iv.$encode_crypttext;
 $encode_get_params = base64_encode($encode_crypttext);

//decrpytion
 $decode_iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
 $decode_get_params = base64_decode($encode_get_params);
 $decode_iv = substr($decode_get_params, 0, $decode_iv_size);
 $dec_ciphertext = substr($decode_get_params, $decode_iv_size);
 $get_params2 =  mcrypt_decrypt(MCRYPT_RIJNDAEL_128, 'b54763051cef08bc', $dec_ciphertext, MCRYPT_MODE_CBC, $decode_iv);

问题是get_params2给了我“%3F%3F”我想回日本字符。它的工作正常与英文文本。 base64编码有问题吗?

谢谢,

0 个答案:

没有答案