November 18, 2011

Code for Password Hashing in ASP.NET

Below is the simplest method to Hash Passwords in ASP.NET





using System.Web.Configuration;
using System.Web.Security;



protected void btnRegister_Click(object sender, EventArgs e)
    {
        string strUserInputtedHashedPassword =
             FormsAuthentication.HashPasswordForStoringInConfigFile(
                                      txtPwd.Text, "sha1");
        //Write code to insert above password in DB
    }





 protected void btnLogin_Click(object sender, EventArgs e)
    {
        string strUserInputtedHashedPassword =
             FormsAuthentication.HashPasswordForStoringInConfigFile(
                                      txtPwd.Text, "sha1");
        //Write code to Match above password  From DB
    }

No comments:

Post a Comment