Visual Basic Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

VB Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
RSA Encryption
S/MIME
Socket
Spider
String
Tar
Unicode
Upload
XML
XMP
Zip Compression

More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor


VB Strings
VB Byte Array

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

 

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")

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2008 Chilkat Software, Inc. All Rights Reserved.