Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
VB
Public Function URLDecrypt(ByVal oKey As String, ByVal oValue As String) As String
       '***************************************
       '***Symmetric Encryption
       '***************************************
       Dim str As String
       If System.Configuration.ConfigurationSettings.AppSettings.Get("URLEncrypt.Mode").ToUpper = "ON" Then
           Dim objSym As New FE_SymmetricNamespace.FE_Symmetric
           'oValue = System.Web.HttpUtility.UrlDecode(oValue)
           str = objSym.DecryptData(oKey, System.Text.Encoding.ASCII.GetString(Convert.FromBase64String(Server.UrlDecode(oValue))))
           'str = objSym.DecryptData(oKey, HttpUtility.UrlDecode(oValue, System.Text.Encoding.Default))
       Else
           str = oValue
       End If

       Return str

   End Function

   Public Function URLEncrypt(ByVal oKey As String, ByVal oValue As String) As String
       '***Symmetric Encryption
       '***************************************
       Dim str As String
       If System.Configuration.ConfigurationSettings.AppSettings.Get("URLEncrypt.Mode").ToUpper = "ON" Then
           Dim objSym As New FE_SymmetricNamespace.FE_Symmetric
           'str = objSym.EncryptData(oKey, oValue)
           '''''''''''''''''''''''''''''''''''''''''''''''''''''
           ' convert to base64 before server.urlencode to remove special characters "+" and "=="
           '''''''''''''''''''''''''''''''''''''''''''''''''''''
           str = Server.UrlEncode(Convert.ToByte(System.Text.Encoding.ASCII.GetBytes(objSym.EncryptData(oKey, oValue))))
           'str = HttpUtility.UrlEncode(objSym.EncryptData(oKey, oValue).TrimEnd("=="), System.Text.Encoding.Default)
           'str = System.Web.HttpUtility.UrlEncode(str)
       Else
           str = oValue
       End If

       Return str

   End Function

Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900