예제 #1
0
        //opens the admin button, after the user successfully puts in our secret password
        private void AdminButton_Click(object sender, RoutedEventArgs e)
        {
            PasswordWindow ap = new PasswordWindow("");

            ap.ShowDialog();

            //This is also terrible, but easy to use... but still, we should move this out to a file somewhere
            //because this is dumb
            //and bad, and should be fixed if we want to do this correctly
            //woot woot for hardcoded passwords....
            if (ap.Password == "couglolz")   // open admin window only if password is correct
            {
                AdminWindow aw = new AdminWindow(this);
                aw.ShowDialog(); // keeps admin window on top of all other windows, preventing multiple admin windows from opening
            }
        }
예제 #2
0
        //  Public Functions    ///////////////////////////////////////////////////////////////////

        public bool Authenticate()
        {
            RegistryKey reg = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\CustomerLogger");
            string      sStoredPassword;

            try
            {
                //Grab the registry entry for admin password
                sStoredPassword = reg.GetValue("Admin_Password").ToString();
            }
            catch (Exception E)
            {
                //The password is not stored yet
                //Ask the user for a new one, then store it in a new registry entry
                NewPasswordWindow NewPasswordWindow = new NewPasswordWindow();
                NewPasswordWindow.ShowDialog();
                //Now grab the entry
                sStoredPassword = reg.GetValue("Admin_Password").ToString();
            }

            //Unescape the hashed string as all '\' are doubled when converted to string
            sStoredPassword = Regex.Unescape(sStoredPassword);

            //Open password window
            PasswordWindow passwordWindow = new PasswordWindow();

            passwordWindow.ShowDialog();

            //Hash user-input password
            byte[] data = System.Text.Encoding.ASCII.GetBytes(passwordWindow.Password);
            data = new System.Security.Cryptography.SHA256Managed().ComputeHash(data);
            string sHashedPassword = System.Text.Encoding.ASCII.GetString(data);

            if (sHashedPassword == sStoredPassword) //If the two hashes match
            {
                return(true);                       //Return true
            }
            else                                    //Else
            {
                return(false);                      //Return false
            }
        }
예제 #3
0
        //opens the admin button, after the user successfully puts in our secret password
        private void AdminButton_Click(object sender, RoutedEventArgs e) {

            PasswordWindow ap = new PasswordWindow("");
            ap.ShowDialog();

            //This is also terrible, but easy to use... but still, we should move this out to a file somewhere
            //because this is dumb
            //and bad, and should be fixed if we want to do this correctly
            //woot woot for hardcoded passwords....
            if (ap.Password == "couglolz") { // open admin window only if password is correct
                AdminWindow aw = new AdminWindow(this);
                aw.ShowDialog(); // keeps admin window on top of all other windows, preventing multiple admin windows from opening
            }
        }