0

Ok, I have an xml document which is returned via a c# function and output via XSLT. In the XML document there is an encrypted string which I need to decrypt before output.

Basically, i need to run "encryptedstring" through a decrypting function in order get the real value.

XML Structure:

<root>
<order encryptedstring="676696969hjhig">
</root>

Outputting function:

XmlDocument xmlOrders = Data_Functions.Get_All_Orders();
xmlOutput.DocumentContent = xmlOrders.OuterXml;

I am assuming i need to loop through the XML document, get the value for each "encryptedstring", run that value through the decrypt function and re-inject it back into the xml document but am unsure of best way to go about that.

The decryption has to be done in the codebehind in c# by passing a string through decryptString();

1

1 Answer 1

0

With a bit of guidance from the question suggestion by @momar this was solved in the following way...

XmlNodeList aNodes = xmlOrders.SelectNodes("//root/order");

        foreach (XmlNode aNode in aNodes)
        {
            XmlAttribute ccAttribute = aNode.Attributes["encryptedstring"];

            string attValue= ccAttribute.Value;
            string encKey = ConfigurationManager.AppSettings["EncryptionKey"];
            string decrypt = Crypto.DecryptStringAES(attValue, encKey);

            ccAttribute.Value = deencrypt;

        }
xmlOutput.DocumentContent = xmlOrders.OuterXml;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.