Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
AES Encrypt Byte Array
Visual Basic code to AES encrypt a byte array. Dim crypt As New ChilkatCrypt2 ' Any string argument automatically begins the 30-day trial. Dim success As Long success = crypt.UnlockComponent("30-day trial") If (success <> 1) Then MsgBox "Crypt component unlock failed" Exit Sub End If ' Use 128-bit AES encryption, in CBC mode. crypt.CryptAlgorithm = "aes" crypt.CipherMode = "cbc" crypt.KeyLength = 128 ' Create a byte array for our secret key and ' initialization vector: ' this byte array has 16 bytes (i.e. 128 bits) Dim key(15) As Byte For i = 0 To 15 key(i) = i Next Dim iv(15) As Byte For i = 0 To 15 iv(i) = i Next ' Create a byte array to be encrypted. Dim data(255) As Byte For i = 0 To 255 data(i) = i Next crypt.SecretKey = key crypt.IV = iv Dim encryptedBytes() As Byte encryptedBytes = crypt.EncryptBytes(data) ' How many bytes in the encrypted output? MsgBox UBound(encryptedBytes) ' Display the encrypted bytes in hex: Text1.Text = crypt.Encode(encryptedBytes,"hex") ' Decrypt the data and show the decrypted data in hex: Dim decryptedBytes() As Byte decryptedBytes = crypt.DecryptBytes(encryptedBytes) Text1.Text = Text1.Text & vbCrLf & crypt.Encode(decryptedBytes, "hex") |
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.