Wednesday, June 16, 2010

How to encrapt Qery string

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
If Session("SessionUserName") IsNot Nothing Then
strUserId = Session("SessionUserName").ToString()
Dim strUid = b64encode(strUserId)
lnk1.NavigateUrl = "ShowHoroscope.aspx?UI=" + strUid + "&Id=1"
End If

End If

End Sub



Public Shared Function b64encode(ByVal StrEncode As String) As String

Dim encodedString As String

encodedString = (Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(StrEncode)))

Return (encodedString)

End Function

Public Shared Function b64decode(ByVal StrDecode As String) As String

Dim decodedString As String

decodedString = System.Text.ASCIIEncoding.ASCII.GetString(Convert.FromBase64String(StrDecode))

Return decodedString

End Function

No comments: