Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8571733
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:50:47+00:00 2026-06-11T18:50:47+00:00

I have this simple Xml file <Root> <Licence Name=My name Age=23/> </Root> During my

  • 0

I have this simple Xml file

<Root>
    <Licence Name="My name" Age="23"/>
</Root>

During my encryption and decryption process, I’m using ToBase64String() andFromBase64String() methods, but it does not seam to work, when I try to decrypt the file, the <> witch limit my Licence element are lost. here’s the result after encryption and decryption :

<Root>&lt;Licence Name="My name" Age="23" /&gt;</Root>

Here is my code

//Encrypt
private void bnEncrypt_Click(object sender, EventArgs e)
{
        var xDoc = XElement.Load(@"C:\Opticien\Lic.xml");
        var data = xDoc.Element("Licence").ToString();

        var dataByte = Encoding.UTF8.GetBytes(data);
        var dataEncrypted = Convert.ToBase64String(dataByte);

        xDoc.SetValue(dataEncrypted);
        xDoc.Save(@"C:\Opticien\Lic.xml");
        memoEdit1.Text = xDoc.ToString();
}

//Decrypt
private void bnDecrypt_Click(object sender, EventArgs e)
{
        var xDoc = XElement.Load(@"C:\Opticien\Lic.xml");
        var data = xDoc.Value;

        var dataByte = Convert.FromBase64String(data);
        var dataDecrypted = Encoding.UTF8.GetString(dataByte);

        xDoc.SetValue(dataDecrypted);
        xDoc.Save(@"C:\Opticien\Lic.xml");
        memoEdit1.Text = xDoc.ToString();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:50:49+00:00Added an answer on June 11, 2026 at 6:50 pm

    You are using SetValue in xDoc.SetValue(dataDecrypted);. This sets the text of the <Root> node, escaping any special characters like the ‘<‘ and ‘>’ characters.

    Instead, use XElement.Parse() to create a new XElement based in the decoded (rather than decrypted) string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this simple XML file : <?xml version=1.0 encoding=utf-8 ?> <Artists> <artist artistId=1>
It seems I can't easily have an XSD declaration for this simple XML <root>
I have a simple doc.xml file which contains a single root element with a
We have an XML file with a very simple implementation of XLink : <root
I have a simple XML file that looks something like: <Institutions> <FI name =
So I have some xml file like this: <?xml version=1.0 encoding=ISO-8859-1?> <root result=0 >
I have a simple problem with XML got from database. Now, this XML can
I have the following XML <ns0:Root xmlns:ns0=http://Map_Sample.Input_Schema> <Number1> </Number1> <Number2>11</Number2> <Number3>12</Number3> </ns0:Root> In this
I have this simple code, using Joda-time. Works fine, but I have a problem.
i have simple XML file: <MyRoot> <Value key=TARGET>foo</Value> <Value key=MODEL>bar</Value> <Value key=MANUFACTURER>bla</Value> </MyRoot> and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.