Dev Direct Solution Center

For more information and to buy this product...

Using wodCrypt to encrypt a local file

  For a copy of the sample project please click here to download and install the product evaluation.

Introduction

wodCrypt is a lightweight component that provides strong encryption for your applications. Whenever you need to secure your transactions, wodCrypt's cryptography can be used. It provides support for most common crypto algorithms.

Detail

P>Our demonstration code illustrates a case in which we take a local file, and encrypt it using the Blowfish algorithm. The whole process is done in three easy steps.

The steps include declaration and initialization of objects, setting the parameters, and encrypting.

Set up

Download and run the executable using the above link. The samples will be placed in the directory C:\Program Files\WeOnlyDo.Com\Crypt\Samples. There are example projects included for C#, VB, ASP, Delphi, VC and VBS.

In the VB6 project, add a reference to wodCryptCOM and event handlers will be provided by the development environment.

In C#, wodCrypt is referenced as WODCRYPTCOMLib, and the all the necessary code is in Form_Load Event.

VB6
Dim wodCrypt As wodCryptCom Dim InFile As FileBlob, OutFile As FileBlob Set wodCrypt = New wodCryptCom Set InFile = New FileBlob Set OutFile = New FileBlob
C#
WODCRYPTCOMLib.wodCryptCom wodCrypt = new WODCRYPTCOMLib.wodCryptCom(); WODCRYPTCOMLib.FileBlobClass InFile = new WODCRYPTCOMLib.FileBlobClass(); WODCRYPTCOMLib.FileBlobClass OutFile = new WODCRYPTCOMLib.FileBlobClass();

The first step is to declare and initialize our objects that we will use to achieve our goal. The code shown above is all you need for this step.

The settings

In order to perform the encryption we need to "tell" the component to perform the encryption using "Blowfish" algorithm, as well as pass it the file that will be encrypted.

VB6
InFile.FileName = "input.filename.goes.here" OutFile.FileName = "output.filename.goes.here" wodCrypt.Type = Blowfish wodCrypt.SecretKey = "secret" wodCrypt.Optimized = False
C#
InFile.Filename = "input.filename.goes.here"; OutFile.Filename = "output.filename.goes.here"; wodCrypt.Type = WODCRYPTCOMLib.CryptoTypes.Blowfish; wodCrypt.SecretKey = "secret"; wodCrypt.Optimized = false;

In the above code, the input file (the file that we wish to encrypt) is set thru FileName property of the InFile object. The Output file (the file that will hold the encrypted data) is specified in FileName property of OutFile object. The Type parameter specifies the encryption algorithm that we want to use, SecretKey is the password (can be used later for decryption). Optimized determines if we want other components/libraries to be able to decrypt the file or not.

The Final step

All we need to do now is call the Encrypt method:

VB6
wodCrypt.Encrypt InFile, OutFile
C#
wodCrypt.Encrypt((WODCRYPTCOMLib.Blob)InFile,(WODCRYPTCOMLib.Blob)OutFile);

Once finished, the output will be in the file specified as FileName property of the OutFile property, and will be encrypted.

Summary

This simple demonstration shows an easy way to encrypt a file in three simple steps by using wodCrypt.

Visit WeOnlyDo! Inc. for more information and more samples.