void logButton_Click(object sender, EventArgs e) { gymstatDB mydb = new gymstatDB(); if (crypto.sha256_hash(passwordText.Text) == mydb.getHashedPassword(usernameText.Text)) { crypto.installCookies(Response.Cookies, usernameText.Text, crypto.sha256_hash(passwordText.Text)); Response.Redirect("LoginSuccess.aspx"); } }
internal static bool validateCookies(HttpCookieCollection cook, bool test) { if ((cook["username"] != null) && cook["secureCookie"] != null) { gymstatDB mydb = new gymstatDB(); string username = cook["username"].Value; string hashedpw = mydb.getHashedPassword(username); string trueHashed = crypto.sha256_hash(hashedpw + username); if (cook["secureCookie"].Value == trueHashed) { return(true); } else { return(false); } } else { return(false); } }
internal static string validateCookies(HttpCookieCollection cook) { if ((cook["username"] != null) && cook["secureCookie"] != null) { gymstatDB mydb = new gymstatDB(); crypto mycrypto = new crypto(); string username = cook["username"].Value; string hashedpw = mydb.getHashedPassword(username); string trueHashed = crypto.sha256_hash(hashedpw + username); if (cook["secureCookie"].Value.StartsWith(trueHashed)) { return(username); } else { return(""); } } else { return(""); } }