我试图解密在德尔福与Cipher1 3.0加密C#一个字符串,德尔福加密提纲A部分我。 我使用TCipher_Rijndael。加密字符串从德尔福C#
串,我加密是:这-是-A-测试示例
密码:通过
加密的值是:iKBC8kX4ZEk4A1pCj6jwEegqjpxhqw ==
当我尝试在c#i到解密此recive错误:解密数据的长度无效。
有没有人有同样的问题,什么是解决方案吗?
这里是C#中的解密方法:
public static byte[] Decrypt(byte[] cipherData,
byte[] Key, byte[] IV)
{
MemoryStream ms = new MemoryStream();
Rijndael alg = Rijndael.Create();
alg.Key = Key;
alg.IV = IV;
CryptoStream cs = new CryptoStream(ms,
alg.CreateDecryptor(), CryptoStreamMode.Write);
cs.Write(cipherData, 0, cipherData.Length);
cs.Close();
byte[] decryptedData = ms.ToArray();
return decryptedData;
}
这里是加密代码德尔福:
with TCipher_Rijndael.Create('pass', nil) do
begin
memo2.lines.add (CodeString('this-is-a-test-example' , paEncode, fmtDEFAULT));
Free;
end;
感谢。
这种编码问题的气味 - 你如何在两个应用程序转换为字符串? – 2011-04-16 23:46:18
在尝试解密之前,您是否将字符串解码为字节数组?您输入的加密字符串使用Base64编码进行编码 - 最后两个等号表示赠品。所以首先你必须使用Convert.FromBase64String将它们转换为一个字节数组。 – 2011-04-16 23:54:53
当然,我将字符串转换为字节数组。 – buda 2011-04-17 00:01:57