Here is my code to encrypt password
Expand|Select|Wrap|Line Numbers
- Dim a, enc As String
- Private Sub encrypt(ByVal a)
- Try
- Dim encData_byte() As Byte = System.Text.Encoding.ASCII.GetBytes(a)
- enc = Convert.ToBase64String(encData_byte)
- TextBox4.Text = enc
- Catch ex As Exception
- MsgBox("Error in Creating Encryption")
- End Try
- End Sub
- Dim str As String = "Data Source=NET3\SQLEXPRESS;Initial Catalog=pos;Persist Security Info=True;User ID=sa;Password=password"
- Dim ds As New DataSet
- Dim adp As New SqlClient.SqlDataAdapter
- Dim con As New SqlClient.SqlConnection
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- If TextBox3.Text <> "" Then
- Call encrypt(TextBox3.Text)
- Else
- MsgBox("Field Missing", MsgBoxStyle.OkOnly, "Error")
- Try
- con.ConnectionString = str
- adp = New SqlClient.SqlDataAdapter("insert into Login(userid,username,password) values ('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox4.Text + "') ", con)
- adp.Fill(ds)
- MsgBox("Inserted", MsgBoxStyle.OkOnly, "Message")
- Catch ex As Exception
- MsgBox(ex.Message)
- End Try
- End If
- End Sub
- End Class