Sub AES_Encrypt(Inputdata() As Byte) As Byte()
Dim data(0) As Byte, iv(0) As Byte
iv = Array As Byte(0x24,0xD7,0x55,0x68,0xBA,0x2F,0x34,0x17,0x39,0x07,0xDA,0x66,0x61,0x19,0x38,0x7B) 'iv (initialisation vector)
Dim kg As KeyGenerator ,c As Cipher
c.Initialize("AES/CBC/PKCS5Padding") ' using 01 0202 030303 04040404 <-- padding method public-key cryptography standards five - PKCS5/PKCS7
' CBC needs an initialisation vector
c.InitialisationVector = iv
kg.Initialize("AES")
kg.KeyFromBytes(Array As Byte(0x11,0x56,0x7E,0x42,0xC1,0x9A,0x23,0x9A,0x46,0xA7,0xCE,0x93,0xDE,0xD5,0x55,0x92) ) 'Key
data = c.Encrypt(Inputdata, kg.key, True)
Return data
End Sub
Sub AES_Decrypt(Inputdata() As Byte) As Byte()
Dim data(0) As Byte, iv(0) As Byte
iv = Array As Byte(0x24,0xD7,0x55,0x68,0xBA,0x2F,0x34,0x17,0x39,0x07,0xDA,0x66,0x61,0x19,0x38,0x7B) 'iv (initialisation vector)
Dim kg As KeyGenerator ,c As Cipher
c.Initialize("AES/CBC/PKCS5Padding") ' using 01 0202 030303 04040404 <-- padding method public-key cryptography standards five - PKCS5/PKCS7
' CBC needs an initialisation vector
c.InitialisationVector = iv
kg.Initialize("AES")
kg.KeyFromBytes(Array As Byte(0x11,0x56,0x7E,0x42,0xC1,0x9A,0x23,0x9A,0x46,0xA7,0xCE,0x93,0xDE,0xD5,0x55,0x92) ) 'Key
data = c.Decrypt(Inputdata, kg.key, True)
Return data
End Sub