In this Post Encrypt Password Before saving into Database Asp.Net
Important Namespaces Used ------------------------ using System.Data; using System.Data.SqlClient; using System.Text; ------------------------- String encrypwd; ------------------------- Signup Button Click Event -------------------------- if(TextBox2.Text==TextBox3.Text) { encryption(); String query = "insert into userlogin(username,password) values('" + TextBox1.Text + "','" + encrypwd +"')"; String mycon = "Data Source=HP-PC\\SQLEXPRESS; Initial Catalog=UserLoginData; Integrated Security=true"; SqlConnection con = new SqlConnection(mycon); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = query; cmd.Connection = con; cmd.ExecuteNonQuery(); Label3.Text = "You Have Successfully Registered"; TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; } else { Label3.Text = "Password and Confirm Password Does not matched"; } --------------------------- User Defined Method ------------------------- public void encryption() { string strmsg = string.Empty; byte[] encode = new byte[TextBox1.Text.ToString().Length]; encode = Encoding.UTF8.GetBytes(TextBox1.Text); strmsg = Convert.ToBase64String(encode); encrypwd= strmsg; } ------------------------