bud*_*uda 3 c# delphi encryption aes
我试图用Delphi Encryption Compendium中的Cipher1 3.0,第一部分解密用Delphi加密的c#中的一个字符串.我使用TCipher_Rijndael.
我加密的字符串是:this-is-a-test-example
密码:通过
加密值为:iKBC8kX4ZEk4A1pCj6jwEegqjpxhqw ==
当我尝试在c#中解密时,我发现错误:要解密的数据长度无效.
有没有人有同样的问题,什么是解决方案?
这是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;
}
Run Code Online (Sandbox Code Playgroud)
这里是Delphi中的加密代码:
with TCipher_Rijndael.Create('pass', nil) do
begin
memo2.lines.add ( CodeString( 'this-is-a-test-example' , paEncode, fmtDEFAULT));
Free;
end;
Run Code Online (Sandbox Code Playgroud)
谢谢.