Imports System.Security.Cryptography Imports System.IO Imports System.Text Public Class MyFunction 'The function used to encrypt the text Public Shared Function Encrypt(ByVal strText As String) As String Dim strEncrKey As String = "txd.v?tx" Dim byKey() As Byte = {} Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF} Try byKey = System.Text.Encoding.UTF8.GetBytes(Left(strEncrKey, 8)) Dim des As New DESCryptoServiceProvider() Dim inputByteArray() As Byte = Encoding.UTF8.GetBytes(strText) Dim ms As New MemoryStream() Dim cs As New CryptoStream(ms, des.CreateEncryptor(byKey, IV), CryptoStreamMode.Write) cs.Write(inputByteArray, 0, inputByteArray.Length) cs.FlushFinalBlock() Return Convert.ToBase64String(ms.ToArray()) Catch ex As Exception Return ex.Message End Try End Function 'The function used to decrypt the text Public Shared Function Decrypt(ByVal strText As String) As String Dim sDecrKey As String = "v59!=cCD" Dim byKey() As Byte = {} Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF} Dim inputByteArray(strText.Length) As Byte Try byKey = System.Text.Encoding.UTF8.GetBytes(Left(sDecrKey, 8)) Dim des As New DESCryptoServiceProvider() inputByteArray = Convert.FromBase64String(strText) Dim ms As New MemoryStream() Dim cs As New CryptoStream(ms, des.CreateDecryptor(byKey, IV), CryptoStreamMode.Write) cs.Write(inputByteArray, 0, inputByteArray.Length) cs.FlushFinalBlock() Dim encoding As System.Text.Encoding = System.Text.Encoding.UTF8 Return encoding.GetString(ms.ToArray()) Catch ex As Exception Return ex.Message End Try End Function End Class