我必须匹配的输出来自Java DESede,使用2005年的BouncyCastle Jar ......我非常接近...
这是我在Java中的输出(这是正确的),然后是我在C#中的输出...如果你在编辑器中查看,你会看到它们几乎匹配,除了在C#中它有正斜杠" /"在Java中它有"%2F","%2D"并且在C#拥有的最后是" =" ,Java有"%3D"。有任何想法吗? (我添加了空格来表示它们匹配 - 但你只能在编辑器中看到它们。)
F3e8sdZ%2F951IRiguIAVqfDLyWptqlbWik5tvFzItcxJCEmupzD9wXp%2BDzIbrf2J2dPpXyEXL2QU%3D(Java - 正确)
F3e8sdZ / 951IRiguIAVqfDLyWptqlbWik5tvFzItcxJCEmupzD9wXp + DzIbrf2J2dPpXyEXL2QU =(C# - 关闭?)
这是我的C#代码:
public static string DoubleTrippleDESede(string strToEncode, ref string symKey, ref ICryptoTransform cipher)
{
try
{
//byte[] input = Encoding.UTF8.GetBytes("DESede (3DES) Encryption in RAILO CFML");
byte[] input = Encoding.UTF8.GetBytes(strToEncode);
//byte[] key = Convert.FromBase64String("ru8femXhTm9jwdGdhb/4Sw==");
byte[] key = Convert.FromBase64String(symKey);
TripleDESCryptoServiceProvider algorithm = new TripleDESCryptoServiceProvider();
algorithm.Mode = CipherMode.ECB;
algorithm.BlockSize = 64;
algorithm.KeySize = 192; // 24 byte key
algorithm.Key = key; //Original
//algorithm.Key = key.CopyTo(algorithm.Key,)
cipher = algorithm.CreateEncryptor();
byte[] encrypted = cipher.TransformFinalBlock(input, 0, input.Length);
Debug.WriteLine("encrypted (.NET): {0}", Convert.ToBase64String(encrypted));
return Convert.ToBase64String(encrypted);
}
catch (Exception ex)
{
return ex.Message;
}
}
任何指导都将非常感谢!!!!我已经在这里工作了两个星期,最终可以尝到胜利(我想!?)