我試圖解密在德爾福與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