Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: C#C#4.0
Hi all, a have a 1 file database xml, I add it to my Project Winform C#, now I want when I debug it show a value of element/node bookID had Encryption by method Encryption MD5 or SHA in textbox, Are you understand ? Now here is xml file, picture demo and code, please fix for me, thank very much:
<?xml version="1.0" encoding="utf-8"?>
Here is a picture when I debug, it haven't still encryption bookID:
Here is picture required I want when debug finish:
Here is my code:
 private void Form1_Load(object sender, EventArgs e)
            XmlDocument xml = new XmlDocument();
            XmlNodeList xnList = xml.SelectNodes("/data[bookID]");
            foreach (XmlNode xn in xnList)
                XmlNode encryption = xn.SelectSingleNode("bookID");
                if (encryption != null)
                    string pass = encryption["bookID"].InnerText;
                    XmlNodeList CNodes = xn.SelectNodes("book");
                    foreach (XmlNode node in CNodes)
                        XmlNode encryption1 = node.SelectSingleNode("bookID");
                        if (encryption1 != null)
                            string md5 = EncrypSHA1(encryption1["bookID"].InnerText);
        private void LoadXml(string FILE_NAME)
            if (!File.Exists(FILE_NAME))
                MessageBox.Show("No find database!", "Notify!", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
            StreamReader sr = File.OpenText(FILE_NAME);
            String input;
            input = sr.ReadToEnd();
            textBox1.Text = input;
        private static string EncrypSHA1(string sMaHoa)
            UTF32Encoding utf32 = new UTF32Encoding();
            byte[] bytes = utf32.GetBytes(sMaHoa);
            SHA1 md = new SHA1CryptoServiceProvider();
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] kq = md.ComputeHash(bytes);
            byte[] kq2 = md5.ComputeHash(kq);
            return Convert.ToBase64String(kq2);
Posted 18-Nov-12 23:26pm
Edited 18-Nov-12 23:36pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Dnyaneshwar@Pune 1,300
1 Sergey Alexandrovich Kryukov 667
2 Tadit Dash 350
3 ravikhoda 300
4 Manas Bhardwaj 240
0 Sergey Alexandrovich Kryukov 11,224
1 OriginalGriff 6,897
2 Peter Leow 4,795
3 Abhinav S 3,838
4 Maciej Los 3,575

Advertise | Privacy | Mobile
Web01 | 2.8.140421.2 | Last Updated 19 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid