private void OkButton_Click(object sender, EventArgs e) { if ((PassEntry1.Text == PassEntry2.Text) && String.IsNullOrEmpty(PassEntry1.Text) == false && String.IsNullOrEmpty(PassEntry2.Text) == false) { if (KeyFileCheckBox.Checked) { if (FileOP.GetKeyFile() != "" && FileOP.GetKeyFile() != null && File.Exists(FileOP.GetKeyFile())) { Compressor.Compress(FileOP.GetFile()); Crypto.EncryptFile(FileOP.GetFile(), PassEntry1.Text); Crypto.EncryptFile(FileOP.GetFile(), FileOP.KeyFileToBits(FileOP.GetKeyFile())); KeyFileLocationText.Text = FileOP.GetKeyFile(); FileOP.ClearKeyFile(); MasterPasswordPrintPopUp printPopUp = new MasterPasswordPrintPopUp(PassEntry1.Text); printPopUp.ShowDialog(); FileOP.ClearFile(); this.Close(); } else { MessageBox.Show("Your key file is invalid. Please reselect your keyfile.", "File Error", MessageBoxButtons.OK); } } else { Compressor.Compress(FileOP.GetFile()); Crypto.EncryptFile(FileOP.GetFile(), PassEntry1.Text); MasterPasswordPrintPopUp printPopUp = new MasterPasswordPrintPopUp(PassEntry1.Text); printPopUp.ShowDialog(); FileOP.ClearFile(); this.Close(); } } else { string message = "Your passwords do not match or the boxes are blank. Please try entering them again"; string title = "Pass Keeper"; MessageBoxButtons buttons = MessageBoxButtons.OK; _ = MessageBox.Show(message, title, buttons); } }
private void Confirm_Click(object sender, EventArgs e) { if (KeyfileLocation.TextLength > 0) { if (!Crypto.DecryptFile(FileOP.GetFile(), FileOP.KeyFileToBits(KeyfileLocation.Text))) { MessageBox.Show("Inncorrect Credentials. Please Try Again.", "Access Denied", MessageBoxButtons.OK); KeyfileLocation.ResetText(); } else if (!Crypto.DecryptFile(FileOP.GetFile(), passwordEntry.Text)) { Crypto.EncryptFile(FileOP.GetFile(), FileOP.KeyFileToBits(KeyfileLocation.Text)); MessageBox.Show("Inncorrect Credentials. Please Try Again.", "Access Denied", MessageBoxButtons.OK); KeyfileLocation.ResetText(); } else { FileOP.LoadKeyFile(KeyfileLocation.Text); Crypto.mPassTemp = passwordEntry.Text; Compressor.Decompress(FileOP.GetFile()); TheParent.PerformRefresh(true); success = true; this.Close(); } } else if (!Crypto.DecryptFile(FileOP.GetFile(), passwordEntry.Text)) { MessageBox.Show("Inncorrect Credentials. Please Try Again.", "Access Denied", MessageBoxButtons.OK); KeyfileLocation.ResetText(); } else { Crypto.mPassTemp = passwordEntry.Text; Compressor.Decompress(FileOP.GetFile()); TheParent.PerformRefresh(true); success = true; this.Close(); } }