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

 

 

 

 

 

 

Zip Compress and Encrypt

Download: Chilkat .NET Assemblies

Use Chilkat Crypt .NET encryption component to Zip compress and encrypt data, and then unzip and decrypt.

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        ' Read a text file to be zipped and encrypted.
        Dim oFile As System.IO.FileInfo
        oFile = New System.IO.FileInfo("test.txt")

        Dim oFileStream As System.IO.FileStream = oFile.OpenRead()
        Dim lBytes As Long = oFileStream.Length

        Dim barrFile(lBytes) As Byte

        ' Read the file into a byte array
        oFileStream.Read(barrFile, 0, lBytes)
        oFileStream.Close()

        ' Create the crypt object, unlock it, set the password and algorithm.
        Dim ckCrypt As Chilkat.Crypt
        ckCrypt = New Chilkat.Crypt()
        ckCrypt.UnlockComponent("UnlockCode")
        ckCrypt.SetSecretKeyViaPassPhrase("MySecretPassword")
        ckCrypt.SetAlgorithmBlowfish()

        ' Zip compress and encrypt the data.
        Dim barrCrypt() As Byte
        barrCrypt = ckCrypt.ZipAndEncrypt(barrFile)

        ' Now decrypt and unzip.
        Dim barrDecrypt() As Byte
        barrDecrypt = ckCrypt.DecryptAndUnzip(barrCrypt)

        ' Display the encrypted and unencrypted sizes.
        Label1.Text = "encrypt size = " + Str(barrCrypt.Length) + ", decrypt size = " + Str(barrDecrypt.Length)

        ' Write the decrypted data to an output file.
        oFileStream = New System.IO.FileStream("out.txt", System.IO.FileMode.Create)
        oFileStream.Write(barrDecrypt, 0, barrDecrypt.Length - 1)
        oFileStream.Close()

    End Sub


Important: The download for this example does not contain the ChilkatDotNet.dll which
must be downloaded and installed separately at http://www.chilkatsoft.com/downloads.asp.
Once installed, add a reference to the DLL in the project by following the instructions at
http://www.example-code.com/vbdotnet/step2.asp

 
 

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

Mail Component · XML Parser