Encoding the Connection String - Code for encoding and decoding
(Page 3 of 5 )
The code for the button click events for the above web form page is as shown here. Button1 is for encoding and Button2 is for decoding.
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim strgToEncode As String
strgToEncode = TextBox1.Text
Dim encodedStrg As String
encodedStrg = Convert.ToBase64String(System.Text. _
ASCIIEncoding.ASCII.GetBytes(strgToEncode))
'Takes the string in the textbox 1 and converts it to
'ascii bytes TextBox2.Text = encodedStrg
TextBox3.Text = TextBox2.Text
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button2.Click
Dim decodedStrg As String
decodedStrg = System.Text.ASCIIEncoding.ASCII. _
GetString(Convert.FromBase64String(TextBox3.Text))
'takes the bytes and converts to string TextBox4.Text = decodedStrg
End Sub
Next: SQL Connection String in configuration file >>
More ASP.NET Articles
More By Jayaram Krishnaswamy