VB.NET Examples

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

VB.NET Examples

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

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

Byte Array
VB.NET FTPS
System.IO

 

 

 

 

 

 

File Encryption / Decryption

Download: Chilkat .NET Assemblies

File-to-file encryption in VB.NET using AES, Blowfish, RC2, ARC4, or 3DES.

Dim crypt As New Chilkat.Crypt2()

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


crypt.CryptAlgorithm = "aes"
crypt.CipherMode = "cbc"
crypt.KeyLength = 128

Dim key As String
'  16 bytes of key for 128-bit encryption.
key = "1234567890123456"

'  The IV is equal to the block size of the encryption algorithm.
Dim iv As String
iv = "1234567890123456"

'  Set the key.
crypt.SetEncodedKey(key,"ascii")

'  Set the IV
crypt.SetEncodedIV(iv,"ascii")

'  AES Encrypt the file (the file may be any size because it will
'  stream the file in/out.
success = crypt.CkEncryptFile("hamlet.xml","aesEncrypted.dat")
If (success <> true) Then
    MsgBox(crypt.LastErrorText)
    Exit Sub
End If


'  AES Decrypt the file (the file may be any size because it will
'  stream the file in/out.
success = crypt.CkDecryptFile("aesEncrypted.dat","hamlet_aes.xml")
If (success <> true) Then
    MsgBox(crypt.LastErrorText)
    Exit Sub
End If


MsgBox("AES File Encryption Success.")


'  Now do 3DES file encryption:

'  To use Triple-DES, set the algorithm = "des",
'  and the key length = 168.
'  To use DES, set the key length = 56 bits.
crypt.CryptAlgorithm = "des"
crypt.CipherMode = "cbc"
crypt.KeyLength = 168

'  3DES Encrypt the file
success = crypt.CkEncryptFile("hamlet.xml","tripleDesEncrypted.dat")
If (success <> true) Then
    MsgBox(crypt.LastErrorText)
    Exit Sub
End If


'  3DES Decrypt the file
success = crypt.CkDecryptFile("tripleDesEncrypted.dat","hamlet_3des.xml")
If (success <> true) Then
    MsgBox(crypt.LastErrorText)
    Exit Sub
End If


MsgBox("3DES File Encryption Success.")


'  Do Blowfish file encryption:

'  To use Blowfish, set the algorithm = "blowfish2".
'  The original Chilkat "blowfish" implementation outputs
'  4321 swapped bytes.  "blowfish2" output is in the correct
'  byte order.
crypt.CryptAlgorithm = "blowfish2"
crypt.CipherMode = "cbc"
crypt.KeyLength = 128

'  Blowfish Encrypt the file
success = crypt.CkEncryptFile("hamlet.xml","blowfishEncrypted.dat")
If (success <> true) Then
    MsgBox(crypt.LastErrorText)
    Exit Sub
End If


'  Blowfish Decrypt the file
success = crypt.CkDecryptFile("blowfishEncrypted.dat","hamlet_blowfish.xml")
If (success <> true) Then
    MsgBox(crypt.LastErrorText)
    Exit Sub
End If


MsgBox("Blowfish File Encryption Success.")



'  Do RC2 file encryption:

'  To use RC2, set the algorithm = "rc2".
'  Also, set the Rc2EffectiveKeyLength property.
crypt.CryptAlgorithm = "rc2"
crypt.CipherMode = "cbc"
'  Key length and effective key length should range
'  from 8 to 1024 bits.
crypt.KeyLength = 128
crypt.Rc2EffectiveKeyLength = 128

'  RC2 Encrypt the file
success = crypt.CkEncryptFile("hamlet.xml","rc2Encrypted.dat")
If (success <> true) Then
    MsgBox(crypt.LastErrorText)
    Exit Sub
End If


'  RC2 Decrypt the file
success = crypt.CkDecryptFile("rc2Encrypted.dat","hamlet_rc2.xml")
If (success <> true) Then
    MsgBox(crypt.LastErrorText)
    Exit Sub
End If


MsgBox("RC2 File Encryption Success.")



'  Do ARC4 file encryption:

'  To use ARC4, set the algorithm = "arc4".
crypt.CryptAlgorithm = "arc4"
crypt.KeyLength = 128

'  ARC4 Encrypt the file
success = crypt.CkEncryptFile("hamlet.xml","arc4Encrypted.dat")
If (success <> true) Then
    MsgBox(crypt.LastErrorText)
    Exit Sub
End If


'  ARC4 Decrypt the file
success = crypt.CkDecryptFile("arc4Encrypted.dat","hamlet_arc4.xml")
If (success <> true) Then
    MsgBox(crypt.LastErrorText)
    Exit Sub
End If


MsgBox("ARC4 File Encryption Success.")




 

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

Mail Component · XML Parser