Sub Encrypt(dataToEncrypt As String ) As String
Try
Dim strPWD As String="1234567890123456"
If dataToEncrypt.Trim.Length=0 Then
Return dataToEncrypt
End If
Dim kg As KeyGenerator
Dim c As Cipher
Dim B64 As Base64
Dim bconv As ByteConverter
Dim data(0) As Byte
Dim iv(0) 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(bconv.StringToBytes(strPWD,"ASCII"))
data = bconv.StringToBytes(dataToEncrypt, "ASCII")
data = c.Encrypt(data, kg.Key, True)
Return B64.EncodeBtoS(data, 0, data.Length)
Catch
Log("Encrypt " & LastException)
Return "Error - Encryption failed."
End Try
End Sub