Wednesday, 6 July 2011

Saving user fields in data base by encrypted

//How to Save the Encrypted UserName and Password fields into Database from Registration.aspx page

string un = FormsAuthentication.HashPasswordForStoringInConfigFile(txtUserName.Text, "MD5");
string pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "MD5");
//your code goes here
SqlCommand cmd = new SqlCommand("insert into cust_table(userid,pwd) values('" + un + "','" + pwd + "')", con);
cmd.ExecuteNonQuery();

//How to check the username and passward verification in Login.aspx page


string un = FormsAuthentication.HashPasswordForStoringInConfigFile(txtUserName.Text, "MD5");
string pwd = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "MD5");
//your code goes here
SqlCommand cmd = new SqlCommand("select * from cust_table where userid='" + un + "' and pwd='" + pwd + "'", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);


Tag: saving encrypted data in asp.net, Saving user fields in data base by encrypted

No comments:

Post a Comment

Parsing JSON w/ @ symbol in it

To read the json response like bellow @ concatenated with attribute                             '{ "@id": 1001, "@name&q...