CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2009
    Posts
    34

    How to decrypt data in an XML file?

    ok so I got half-way there, I was able to encrypt an element in my XML file, now I want to learn how to decrypt it.

    Here is my encryption code:

    Code:
                System.Xml.XmlDocument myDoc = new System.Xml.XmlDocument();
                myDoc.Load("settings.xml");
                System.Xml.XmlElement element = myDoc.GetElementsByTagName("TechPass")[0] as System.Xml.XmlElement;
                
                System.Security.Cryptography.TripleDESCryptoServiceProvider tDESkey = new System.Security.Cryptography.TripleDESCryptoServiceProvider();
                
                System.Security.Cryptography.Xml.EncryptedXml encr = new System.Security.Cryptography.Xml.EncryptedXml();
                encr.AddKeyNameMapping("Deskey", tDESkey);
                
                System.Security.Cryptography.Xml.EncryptedData ed = encr.Encrypt(element,"Deskey");
                
                System.Security.Cryptography.Xml.EncryptedXml.ReplaceElement(element, ed, false);
    
                myDoc.Save("settings.xml");
    Any ideas how I reverse it to read the element and decrypt it and read the result to a string?

  2. #2
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: How to decrypt data in an XML file?

    Quote Originally Posted by saldous View Post
    Any ideas how I reverse it to read the element and decrypt it and read the result to a string?
    google? www.google.com
    msdn? http://msdn.microsoft.com/en-us/library/ms229749.aspx
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

  3. #3
    Join Date
    Nov 2009
    Posts
    14

    Re: How to decrypt data in an XML file?

    Memeloo,

    Do you really think you're going to be some kind of "Power Poster" with your BS responses?

  4. #4
    Join Date
    Oct 2008
    Location
    Cologne, Germany
    Posts
    756

    Re: How to decrypt data in an XML file?

    Quote Originally Posted by lexavision View Post
    Do you really think you're going to be some kind of "Power Poster" with your BS responses?
    I don't know. the "BS" abbreviation is unknown to me.
    win7 x86, VS 2008 & 2010, C++/CLI, C#, .NET 3.5 & 4.0, VB.NET, VBA... WPF is comming

    remeber to give feedback you think my response deserves recognition? perhaps you may want to click the Rate this post link/button and add to my reputation

    private lessons are not an option so please don't ask for help in private, I won't replay

    if you use Opera and you'd like to have the tab-button functionality for the texteditor take a look at my Opera Tab-UserScirpt; and if you know how to stop firefox from jumping to the next control when you hit tab let me know

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured