private void btn_Login_Click_1(object sender, EventArgs e) { Account_Service service = new Account_Service(); Account currentUser = new Account(); currentUser.Gebruikersnaam = txtbox_Gebruikersnaam.Text; string salt = service.GetSalt(currentUser); HashAndSalt retrieve = new HashAndSalt(); string hash = retrieve.GenerateHash(txtbox_Wachtwoord.Text, salt); SqlConnection con = new SqlConnection(@"Data Source=den1.mssql8.gear.host;Initial Catalog=pdb1920f6;Persist Security Info=True;User ID=pdb1920f6;Password=Lc9e~P-O3L2d"); SqlDataAdapter sda = new SqlDataAdapter("SELECT COUNT(*) FROM ACCOUNT WHERE Gebruikersnaam ='" + txtbox_Gebruikersnaam.Text + "' AND Hash ='" + hash + "'", con); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows[0][0].ToString() == "1") { this.Hide(); SomerenUI UI = new SomerenUI(); UI.Show(); UI.GetUserName(txtbox_Gebruikersnaam.Text); } else { MessageBox.Show("Foute gebruikersnaam en/of wachtwoord.."); } }
private void btn_registreren_Click(object sender, EventArgs e) { SomerenLogic.Account_Service accountToevoegen = new SomerenLogic.Account_Service(); Account nieuwAccount = new Account(); HashAndSalt hashPassword = new HashAndSalt(); string salt = hashPassword.CreateSalt(64); string hashedWachtwoord = hashPassword.GenerateHash(txtbox_nieuwePassword.Text, salt); nieuwAccount.Gebruikersnaam = txtbox_nieuweUser.Text; nieuwAccount.Wachtwoord = hashedWachtwoord; nieuwAccount.AdminStatus = "user"; nieuwAccount.Vraag = txtBox_geheimeVraag.Text; nieuwAccount.Antwoord = txtBox_geheimAntwoord.Text; nieuwAccount.Salt = salt; if (txtbox_licentieSleutel.Text == "XsZAb-tgz3PsD-qYh69un-WQCEx") { accountToevoegen.AccountToevoegen(nieuwAccount); this.Hide(); LoginScreen loginScreen = new LoginScreen(); loginScreen.Show(); } else { MessageBox.Show("Foute licentieSleutel.."); } }
internal int postUser(User user) { HashAndSalt pwSecurity = new HashAndSalt(); int result = -999999; string password = user.Password; string salt = pwSecurity.getSalt(); //.GenerateHash(password, salt, 0) the last 0 is the starting value for the recursive iteration counter string saltedPassword = pwSecurity.GenerateHash(password, salt, 0); password = ""; //ERASING IT FROM MEMORY user.Password = saltedPassword; user.Salt = salt; rulesencyclopediaDBEntities1 context = new rulesencyclopediaDBEntities1(); try { //getting back the key for the created user. context.User.Add(user); result = context.SaveChanges(); } catch (EntityException ex) { exHandler.exceptionHandlerEntity(ex, "something went wrong when posting user"); } finally { context.Dispose(); } return(result); }
private void btn_enter3_Click(object sender, EventArgs e) { SomerenLogic.Account_Service AccountNewPassword = new SomerenLogic.Account_Service(); Account acc = new Account(); HashAndSalt hashPassword = new HashAndSalt(); string salt = hashPassword.CreateSalt(64); string hashedWachtwoord = hashPassword.GenerateHash(tb_NewPassword.Text, salt); AccountNewPassword.AlterPassword(tb_NewPassword.Text, hashedWachtwoord, salt); string gebruikersnaam = tb_GebruiksN.Text; string wachtwoord = tb_NewPassword.Text; AccountNewPassword.AlterPassword(gebruikersnaam, hashedWachtwoord, salt); MessageBox.Show("Wachtwoord is veranderd"); LoginScreen login = new LoginScreen(); login.Show(); this.Close(); }