xml文件加密
public void Decrypt(XmlDocument Doc,SymmetricAlgorithm Alg){
XmlElement encryptedElement = Doc.GetElementsByTagName("EncryptedData")[0] as XmlElement;
EncryptedData edElement = new EncryptedData();
edElement.LoadXml(encryptedElement);
EncryptedXml exml = new EncryptedXml();
byte[] rgbOutput = exml.DecryptData(edElement,Alg);
exml.ReplaceData(encryptedElement,rgbOutput);
}
//对应解密文件
private void button2_Click(object sender, EventArgs e)
{
RijndaelManaged key = new RijndaelManaged();
byte[] bytekey = Encoding.Unicode.GetBytes("1111111111111111");
key.Key = bytekey;
XmlDocument xmldoc = new XmlDocument();
xmldoc.PreserveWhitespace = true;
xmldoc.Load("网络服务.xml");
Decrypt(xmldoc, key);
if (key != null)
{
key.Clear();
}
xmldoc.Save("网络服务.xml");
}
执行后总是提示未指定密码数据,有人知道是怎么回事吗 --------------------编程问答--------------------
补充:.NET技术 , C#