private void OKButton(object sender, EventArgs e) { string temp = ""; if (CyBLE_MTK_Application.Properties.Settings.Default.Password == "null") { temp = ""; } else { byte[] passtext = ProtectedData.Unprotect(Convert.FromBase64String(CyBLE_MTK_Application.Properties.Settings.Default.Password), null, DataProtectionScope.CurrentUser); temp = ChangePasswordDialog.GetString(passtext); } if (PasswordText.Text == temp) { if (NewPassword.Text == ReEnterNewPassword.Text) { byte[] ciphertext = ProtectedData.Protect(GetBytes(ReEnterNewPassword.Text), null, DataProtectionScope.CurrentUser); CyBLE_MTK_Application.Properties.Settings.Default.Password = Convert.ToBase64String(ciphertext); CyBLE_MTK_Application.Properties.Settings.Default.Save(); Log.PrintLog(this, "Password successfully changed.", LogDetailLevel.LogRelevant); MessageBox.Show("Password successfully changed!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); PasswordChanged = true; this.Close(); } else { Log.PrintLog(this, "Password not changed! Re-entered password doesnot match.", LogDetailLevel.LogEverything); MessageBox.Show("Password not changed! Re-entered password doesnot match.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { Log.PrintLog(this, "Password not changed! Wrong password.", LogDetailLevel.LogEverything); MessageBox.Show("Password not changed!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }