Exemplo n.º 1
0
        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");
            }
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        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("");
            }
        }