'Imports System
'Imports System.IO
'Imports System.Text
'Imports System.Security.Cryptography

'Public Class Crypt
'    Public Shared Function Encrypt(ByVal data As Byte(), ByVal key As String) As Byte()
'        Dim algorithm As New RijndaelManaged()
'        Dim keyData As Byte() = GetKey(key)
'        Dim transform As ICryptoTransform = algorithm.CreateEncryptor(keyData, keyData)
'        Dim memoryStream As New MemoryStream()
'        Dim cryptStream As New CryptoStream(memoryStream, transform, CryptoStreamMode.Write)
'        cryptStream.Write(data, 0, data.Length)
'        cryptStream.FlushFinalBlock()
'        Dim ret As Byte() = memoryStream.ToArray
'        memoryStream.Close()
'        cryptStream.Close()
'        Return ret
'    End Function

'    Public Shared Function Decrypt(ByVal data As Byte(), ByVal key As String) As Byte()
'        Dim algorithm As New RijndaelManaged()
'        Dim keyData As Byte() = GetKey(key)
'        Dim transform As ICryptoTransform = algorithm.CreateDecryptor(keyData, keyData)
'        Dim memoryStream As New MemoryStream(data)
'        Dim cryptStream As New CryptoStream(memoryStream, transform, CryptoStreamMode.Read)
'        Dim readBuffer As Byte() = New Byte(data.Length - 1) {}
'        Dim len As Integer = cryptStream.Read(readBuffer, 0, readBuffer.Length)
'        Dim ret As Byte() = New Byte(len - 1) {}
'        Array.Copy(readBuffer, ret, len)
'        memoryStream.Close()
'        cryptStream.Close()
'        Return ret
'    End Function

'    Private Shared Function GetKey(ByVal keyString As String) As Byte()
'        Dim salt As Byte() = Encoding.ASCII.GetBytes("I must admit I don't have a clue what's this is about.")
'        Dim pdb As PasswordDeriveBytes = New PasswordDeriveBytes(keyString, salt)
'        Return pdb.GetBytes(16)
'    End Function
'End Class