Skip to content

Instantly share code, notes, and snippets.

@ssukhpinder
Created September 21, 2020 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssukhpinder/ffab653a4e75a80301840fe2d59145bb to your computer and use it in GitHub Desktop.
Save ssukhpinder/ffab653a4e75a80301840fe2d59145bb to your computer and use it in GitHub Desktop.
public static void Decrypt(XmlDocument Doc, SymmetricAlgorithm Alg)
{
if (Doc == null)
throw new ArgumentNullException("Doc");
if (Alg == null)
throw new ArgumentNullException("Alg");
XmlElement encryptedElement = Doc.GetElementsByTagName("EncryptedData")[0] as XmlElement;
if (encryptedElement == null)
{
throw new XmlException("The XML element was not found.");
}
EncryptedData edElement = new EncryptedData();
edElement.LoadXml(encryptedElement);
EncryptedXml exml = new EncryptedXml();
byte[] rgbOutput = exml.DecryptData(edElement, Alg);
exml.ReplaceData(encryptedElement, rgbOutput);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment