Public Shared Function Decrypt(ByVal inputInBytes() As Byte) As String Dim tdesProvider As TripleDESCryptoServiceProvider = New TripleDESCryptoServiceProvider() Dim cryptoTransform As ICryptoTransform = tdesProvider.CreateDecryptor(key, iv) Dim decryptedStream As MemoryStream = New MemoryStream() Dim cryptStream As CryptoStream = New CryptoStream(decryptedStream, cryptoTransform, CryptoStreamMode.Write) cryptStream.Write(inputInBytes, 0, inputInBytes.Length) cryptStream.FlushFinalBlock() decryptedStream.Position = 0 Dim result(decryptedStream.Length - 1) As Byte decryptedStream.Read(result, 0, decryptedStream.Length) cryptStream.Close() Dim myutf As UTF8Encoding = New UTF8Encoding() Decrypt = myutf.GetString(result) End Function Public Shared Function Encrypt(ByVal plainText As String) As Byte() Dim inputInBytes() As Byte = Encoding.UTF8.GetBytes(plainText) Dim tdesProvider As TripleDESCryptoServiceProvider = New TripleDESCryptoServiceProvider() Dim cryptoTransform As ICryptoTransform = tdesProvider.CreateEncryptor(key, iv) Dim encryptedStream As MemoryStream = New MemoryStream() Dim cryptStream As CryptoStream = New CryptoStream(encryptedStream, cryptoTransform, CryptoStreamMode.Write) cryptStream.Write(inputInBytes, 0, inputInBytes.Length) cryptStream.FlushFinalBlock() encryptedStream.Position = 0 Dim result(encryptedStream.Length - 1) As Byte encryptedStream.Read(result, 0, encryptedStream.Length) cryptStream.Close() Encrypt = result End Function