Example #1
0
        private void passcode_FormClosing(object sender, FormClosingEventArgs e)
        {
            PassSecurity _PassSecObj = new PassSecurity();
            string       filename    = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\encryptedCode.txt";

            if (File.Exists(filename) == true)
            {
                string decryptedPasscode = _PassSecObj.decryptPasscode(_PassSecObj.fetchPasscodeFromDirectory(filename));
                if (decryptedPasscode != this.checkPasscodeTxtBox)
                {
                    MessageBox.Show("Invalid Passcode", "Program will END");
                    Environment.Exit(1);
                }
                else
                {
                    IspasscodeRight = true;
                }
            }
            else
            {
                MessageBox.Show("Invalid Passcode", "Program will END");
                Environment.Exit(1);
            }
            this.passcodeTxtBox.Clear();
        }
Example #2
0
        private void enterPasscodeButton_Click(object sender, EventArgs e)
        {
            PassSecurity _PassSecObj = new PassSecurity();
            string       filename    = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\encryptedCode.txt";

            checkPasscodeTxtBox = passcodeTxtBox.Text;


            if (!(File.Exists(filename)) && checkPasscodeTxtBox != "" && checkPasscodeTxtBox.Length == 3)
            {
                MessageBox.Show("3 digit Passcode Saved");
                MessageBox.Show(string.Format("WARNING:Dont forget you 3 digit passcode \"{0}\"", checkPasscodeTxtBox));
                MessageBox.Show("if you forget yourpassword view read me");


                _PassSecObj.savePasscode(checkPasscodeTxtBox, filename);
            }
            else if (File.Exists(filename) == true && this.passcodeTxtBox.Text.Length == 3)
            {
                string decryptedPasscode = _PassSecObj.decryptPasscode(_PassSecObj.fetchPasscodeFromDirectory(filename));
                if (decryptedPasscode != this.checkPasscodeTxtBox)
                {
                    MessageBox.Show("Invalid Passcode", "Program will END");
                    Environment.Exit(1);
                }
                else
                {
                    IspasscodeRight = true;
                }
            }
            else
            {
                MessageBox.Show("Invalid Passcode", "Program will END");
                Environment.Exit(1);
            }
            this.passcodeTxtBox.Clear();
            this.Close();
        }