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

 

 

 

 

 

 

 

Matching .NET Framework AES Encryption Results

Download Chilkat Crypt ActiveX

AES string encryption in Visual Basic and the equivalent C# code using the .NET Framework.

'  First, here's the C# code we're trying to match:

'  RijndaelManaged rman = new RijndaelManaged();
'  rman.Mode = CipherMode.CBC;
'  rman.Padding = PaddingMode.PKCS7;
'  rman.KeySize = 256;

'  Use a 32-byte key (for 256-bit encryption)
'  byte [] keyBytes = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
'  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 };

'  The IV for AES is 16 bytes, because the AES block size is 16.
'  byte [] ivBytes = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };

'  ICryptoTransform encryptor = rman.CreateEncryptor(keyBytes, ivBytes);

'  byte [] plainText = System.Text.Encoding.UTF8.GetBytes("This is a test");

'  byte [] encrypted = encryptor.TransformFinalBlock(plainText, 0, plainText.Length);

'  Output is 31k+86baFy9GJKQ9Y1ebCw==
'  textBox1.Text = Convert.ToBase64String(encrypted);

'  The following Chilkat code produces the same output:
Dim crypt As New ChilkatCrypt2

Dim success As Long
success = crypt.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
    MsgBox "Crypt component unlock failed"
    Exit Sub
End If

crypt.CryptAlgorithm = "aes"
crypt.CipherMode = "cbc"
crypt.KeyLength = 256
crypt.PaddingScheme = 0
crypt.EncodingMode = "base64"

Dim ivHex As String
ivHex = "000102030405060708090A0B0C0D0E0F"
Dim keyHex As String
keyHex = "000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F"
crypt.SetEncodedIV ivHex,"hex"
crypt.SetEncodedKey keyHex,"hex"

MsgBox crypt.EncryptStringENC("This is a test")


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