Visual Basic Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SFTP
SMTP
Socket
Spider
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
DH Key Exchange
DSA
FileAccess
RSS
Atom
Self-Extractor
Service
Bzip2
PPMD
Deflate
LZW


VB Strings
VB Byte Array

 

 

 

 

 

 

 

AES Encrypt Byte Array

Download Chilkat Crypt ActiveX

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.