在我知道密码的情况下,如何使用 C# 解密这个 XML 文件?
<EncryptedData xmlns="w3.org/2001/04/xmlenc#"; Type="w3.org/2001/04/xmlenc#Element"; Salt="Gnk/DB61AQ==" IV="iYcfV0NOGy0=">
<EncryptionMethod Algorithm="w3.org/2001/04/xmlenc#tripledes-cbc"; />
<CipherData>
<CipherValue>/TtgJ46P9L23ZeGt67n+2OZGXoHiGWcUAWE8CdN1Z2aiF40fAg6DfBWGx62RB7Botxrw+f1Jf1CtR10iMLw0iz+VIcbaPFZj5ZfCm3aDeDLbnwXdb7mIdzNtF/5EOjNph/kPz7PxcUlAOUvsLLmjGtx92EhWL6KpXufKahnRiwLuZLNc</CipherValue>
</CipherData>
</EncryptedData>
我试过了
public static string Decryption(string CypherText, string key)
{
byte[] b = Convert.FromBase64String(CypherText);
TripleDES des = CreateDES(key);
ICryptoTransform ct = des.CreateDecryptor();
byte[] output = ct.TransformFinalBlock(b, 0, b.Length);
return Encoding.Unicode.GetString(output);
}
但是发生了异常
byte[] 输出 = ct.TransformFinalBlock(b, 0, b.Length); 不良数据