...
Dim code As String = Encrypt("fred was here")
mykey = "123456789012345678901234"
Log(code)
Log(Decrypt(code))
End Sub
Sub Encrypt(dataToEncrypt As String ) As String
Dim kg As KeyGenerator
Dim c As Cipher
Dim B64 As Base64
Dim data() As Byte
Dim iv() As Byte
iv = Array As Byte(211, 5, 233, 24, 55, 166, 7, 88)
c.Initialize("DESede/CBC/PKCS5Padding")
c.InitialisationVector = iv
kg.Initialize("DESede")
kg.KeyFromBytes(mykey.GetBytes("ASCII"))
data = c.Encrypt(dataToEncrypt.GetBytes("ASCII"), kg.Key, True)
Return B64.EncodeBtoS(data, 0, data.Length)
End Sub
Sub Decrypt(encryptedData As String ) As String
Dim kg As KeyGenerator
Dim c As Cipher
Dim B64 As Base64
Dim bconv As ByteConverter
Dim data() As Byte
Dim iv() As Byte
iv = Array As Byte(211, 5, 233, 24, 55, 166, 7, 88) ' 16 bytes for AES
c.Initialize("DESede/CBC/PKCS5Padding")
c.InitialisationVector = iv
kg.Initialize("DESede")
kg.KeyFromBytes(mykey.GetBytes("ASCII"))
data = c.Decrypt(B64.DecodeStoB(encryptedData), kg.Key, True)
Return bconv.StringFromBytes(data, "ASCII")
End Sub