我目前在解密由php mcrypt加密的邮件方面遇到了一些问题.php代码如下:
<?php
//$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
$iv = "45287112549354892144548565456541";
$key = "anjueolkdiwpoida";
$text = "This is my encrypted message";
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_CBC, $iv);
$crypttext = urlencode($crypttext);
$crypttext64=base64_encode($crypttext);
print($crypttext64) . "\n<br/>";
?>
Run Code Online (Sandbox Code Playgroud)
然后将加密的消息发送到ASP.NET平台(C#).但是,我在保留解密顺序(base64解码到urldecode)时遇到问题.我在ASP.NET中的代码如下(iv和key与php中的相同):
public string Decode(string str)
{
byte[] decbuff = Convert.FromBase64String(str);
return System.Text.Encoding.UTF8.GetString(decbuff);
}
static public String DecryptRJ256(string cypher, string KeyString, string IVString)
{
string sRet = "";
RijndaelManaged rj = new RijndaelManaged();
UTF8Encoding encoding = new UTF8Encoding();
try
{
//byte[] message = Convert.FromBase64String(cypher);
byte[] message …Run Code Online (Sandbox Code Playgroud)