Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Zip Compress and EncryptDownload: 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 |
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.