private void btnLogin_Click(object sender, EventArgs e) { //create salt byte[] salt; new RNGCryptoServiceProvider().GetBytes(salt = new byte[SaltSize]); //generate hash with salt string hash = PasswordHashHelper.Hash(txtPassword.Text, salt, 1000); var checkLogin = from cc_users in db.cc_users where cc_users.UserName == txtusername.Text select new { username = cc_users.UserName, password = cc_users.Password, salt = cc_users.Salt }; foreach (var user in checkLogin) { //var saltByte = new byte[user.salt.Length]; if (PasswordHashHelper.Verify(txtPassword.Text, user.password)) { //MessageBox.Show("Passwords Match"); Properties.Settings.Default.Username = txtusername.Text; Properties.Settings.Default.Save(); Dashboard dashboard = new Dashboard(); dashboard.Show(); } else { MessageBox.Show("Login failed"); } } }
public bool VerifyPassword(string hash, string password, bool isDefault) { if (isDefault) { return(hash == password); } return(PasswordHashHelper.Verify(password, hash)); }
public long?SessionId => null; //TODO public bool VerifyPassword(string hash, string password, bool isDefault) { if (isDefault) { throw new InvalidOperationException("Not accessible with default password"); } return(PasswordHashHelper.Verify(password, hash)); }
public async Task <bool> Login(LoginRequest loginRequest) { var context = new DynamoDBContext(_dynamoClient); var scanConditions = new List <ScanCondition> { new ScanCondition("Email", ScanOperator.Equal, new object[] { loginRequest.Email }) }; var config = new DynamoDBOperationConfig() { OverrideTableName = DynamoConstants.CREDENTIALS_TABLE }; var passwordResponse = await context.ScanAsync <PasswordEntryDynamo>(scanConditions, config).GetRemainingAsync(); if (passwordResponse.Count == 0) { throw new InvalidEmailOrPasswordException(); } return(PasswordHashHelper.Verify(passwordResponse[0].PasswordHash, loginRequest.Password)); }
public static void Login() { Linq.dbStructureDataContext db = new Linq.dbStructureDataContext(); Form1 frm = new Form1(); //create salt byte[] salt; new RNGCryptoServiceProvider().GetBytes(salt = new byte[SaltSize]); //generate hash with salt string hash = PasswordHashHelper.Hash(frm.txtNewPass.Text, salt, 1000); var checkLogin = from cc_users in db.cc_users where cc_users.UserName == frm.txtLoginUser.Text select new { username = cc_users.UserName, password = cc_users.Password, salt = cc_users.Salt }; foreach (var user in checkLogin) { //var saltByte = new byte[user.salt.Length]; if (PasswordHashHelper.Verify(frm.txtLoginPass.Text, user.password)) { //MessageBox.Show("Passwords Match"); Properties.Settings.Default.Username = frm.txtLoginUser.Text; Properties.Settings.Default.Save(); Dashboard dashboard = new Dashboard(); dashboard.Show(); } else { MessageBox.Show("Login failed"); } } }