private void CreatePassword(IS2G10_DBSSSDataSet.USERPROFILERow userProfile) { _password = null; var createPasswordWindow = new CreatePassword(); if (createPasswordWindow.ShowDialog() == true) { _password = createPasswordWindow.Password; //values preserved after close } if (_password != null && !_password.Equals("")) { string hash; string salt; _passwordBuilder.CreateHash(_password, out hash, out salt); userProfile.resetPassword = false; userProfile.password_hash = hash; userProfile.password_salt = salt; _userProfileTableAdapter.Update(userProfile); _dialogService.CallMessageModal(this, "", SSS_Library.Properties.Resources.Login_CheckPassword_Password_Created_Successfully); } if (_password != null && _password.Equals("") || _password == null) { _dialogService.CallMessageModal(this, "", SSS_Library.Properties.Resources.Login_CheckPassword_Please_Enter_a_Password_); } }
private void CreatePassword(SSS_Library.IS2G10_DBSSSDataSet.USERPROFILERow userProfile) { _password = null; using (var form = new CreatePassword()) { var result = form.ShowDialog(); if (result == DialogResult.OK) { _password = form.Password; //values preserved after close } } if (_password != null && !_password.Equals("")) { string hash; string salt; _passwordBuilder.CreateHash(_password, out hash, out salt); userProfile.resetPassword = false; userProfile.password_hash = hash; userProfile.password_salt = salt; userprofileTableAdapter1.Update(userProfile); MessageBox.Show(Resources.Login_CheckPassword_Password_Created_Successfully, Resources.Login_CheckPassword_Password_Created_Successfully); medPassword.Clear(); medUsername.Clear(); medUsername.Focus(); } if (_password != null && _password.Equals("")) { MessageBox.Show(Resources.Login_CheckPassword_Please_Enter_a_Password_, Resources.Login_CheckPassword_Please_Enter_a_Password_); } if (_password == null) { MessageBox.Show(Resources.Login_CheckPassword_Please_Enter_a_Password_, Resources.Login_CheckPassword_Please_Enter_a_Password_); } }
public void TestPasswordHasing() { //make a password string test = "HereBeDragons64"; string hash; string salt; _passwordBuilder.CreateHash(test, out hash, out salt); //get back var returnTest = _passwordBuilder.ComputeHash_ShaSalt(test, StringHandler.GetBytes(salt)); var testString = Convert.ToBase64String(returnTest); Assert.AreEqual(testString, hash); //check if check works var check = _passwordBuilder.CheckPassword(test, hash, salt); Assert.IsTrue(check); }