<> Xml lost when converting To and From 64BaseString

unitedonline

New Member
I have this simple Xml file\[code\]<Root> <Licence Name="My name" Age="23"/></Root>\[/code\]I'm trying to encrypt it using \[code\]ToBase64String()\[/code\] method, and then decrypt it using \[code\]FromBase64String()\[/code\] method, but it does not seam to wotk, when I try to decrypt the file, the <> witch limit my Licence element are lost and get replaced by. here's the result after encryption and decryption :\[code\]<Root><Licence Name="My name" Age="23" /></Root>\[/code\]Here is my code\[code\]//Encryptprivate void bnEncrypt_Click(object sender, EventArgs e){ var xDoc = XElement.Load(@"C:\Opticien\Lic.xml"); var data = http://stackoverflow.com/questions/12565694/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();}//Decryptprivate void bnDecrypt_Click(object sender, EventArgs e){ var xDoc = XElement.Load(@"C:\Opticien\Lic.xml"); var data = http://stackoverflow.com/questions/12565694/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();}\[/code\]
 
Back
Top