Esempio n. 1
0
 protected void decryptBtn_Click(object sender, EventArgs e)
 {
     //init new encryption object from StringEncryptDecrpy .dll file
     StringEncryptDecrypt.Encryption encryption = new StringEncryptDecrypt.Encryption();
     //decrpyt the string and display it
     decryptedLbl.Text = encryption.Decrypt(decryptStringInput.Value);
 }
Esempio n. 2
0
        protected bool authenticateUser(string username, string password)
        {
            //init new encryption object using Encryption .dll file
            StringEncryptDecrypt.Encryption encryption = new StringEncryptDecrypt.Encryption();

            //get path for Members.xml file
            string path = AppDomain.CurrentDomain.BaseDirectory;

            path += "App_Data\\Members.xml";             //store to App_Data folder on server?

            //iterate through level 1 elements
            foreach (XElement level1Element in XElement.Load(path).Elements("Members"))
            {
                //iterate through level 2 elements
                foreach (XElement level2Element in level1Element.Elements("Member"))
                {
                    string tempUsername = level2Element.Attribute("username").Value;
                    string tempPassword = encryption.Decrypt(level2Element.Attribute("password").Value);
                    //check each tempUsername/tempPassword against inputted username & password
                    if (username == tempUsername && password == tempPassword)
                    {
                        //both username and password match ->authenticate the user
                        return(true);
                    }
                }
            }

            //no matching username or password found in Members.xml -> do not authenticate the user
            return(false);
        }