我正在尝试在C#中解密使用Delphi Encryption Compendium的Cipher1 3.0加密的一个字符串。我使用的是TCipher_Rijndael。
被加密的字符串为:this-is-a-test-example,
密码为:pass。
加密后的值为:iKBC8kX4ZEk4A1pCj6jwEegqjpxhqw==。
当我尝试在C#中解密时,我收到错误消息:Length of the data to decrypt is invalid。
是否有人遇到了同样的问题,并且知道解决方案?
下面是C#中的解密方法:
谢谢。
被加密的字符串为:this-is-a-test-example,
密码为:pass。
加密后的值为:iKBC8kX4ZEk4A1pCj6jwEegqjpxhqw==。
当我尝试在C#中解密时,我收到错误消息:Length of the data to decrypt is invalid。
是否有人遇到了同样的问题,并且知道解决方案?
下面是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;
}
以下是Delphi中的加密代码:
with TCipher_Rijndael.Create('pass', nil) do
begin
memo2.lines.add ( CodeString( 'this-is-a-test-example' , paEncode, fmtDEFAULT));
Free;
end;
谢谢。