"The code is exactly
how I would like to write code and the algorithms used are very
efficient and well-documented."
Van T. Dinh, Microsoft MVP
|
|
Class: CEncryption
Class that encrypts and decrypts a file or string. This class is Unicode enabled. There are methods included for encrypting both files and strings. This class uses XOR password encryption. The password is also encrypted as the string or file is processed, providing an additional level of security.
|
Procedure Name
|
Type
|
Description
|
|
(Declarations)
|
Declarations
|
Declarations and private variables for the CEncryption class
|
|
InputFileName
|
Property
|
Gets the name of the input file
|
|
OutputFileName
|
Property
|
Gets the name of the output file
|
|
Password
|
Property
|
Gets the password
|
|
Class_Initialize
|
Initialize
|
Set initial values to defaults which may be overridden with property settings
|
|
EncryptByte
|
Private
|
Encrypts one byte, and modifies the password.
Modifying the password as we encrypt makes the encyption slightly harder to break.
|
|
EncryptFile
|
Method
|
Encrypts the file specified in m_strInputFileName to the file specified in m_strOutPutFileName. This procedure uses buffered file reads and writes for better performance.
The encrypted file produced by the method is reversible. This means that if you encrypt a file, reverse the InputFileName and OutputFileName properties, and call this method again, the original file is restored. Please note that the same password must be supplied to successfully decrypt the file.
This method also raises an event called file progress. This event can be used to track the progress of the file being processed. Please see the example tab for an example of how to use this event.
This method also uses a file buffer. Using a file buffer significantly speeds up the performance of this method.
|
|
EncryptString
|
Method
|
Encrypts/Decrypts the passed string with XOR encryption.
The encrypted string produced by the method is reversible. This means that if you encrypt a string, then encrypt the results of that operation, the original string is restored. Please note that the same password must be supplied to successfully decrypt the string.
Please see the example tab for a demonstration of this.
If you need and ASCII version of this function, please see the EncryptStringANSI method.
|
|
EncryptStringAscii
|
Method
|
Encrypts/Decrypts the passed string with XOR encryption, returning the result in ASCII format.
The encrypted string produced by the method is reversible. This means that if you encrypt a string, then encrypt the results of that operation, the original string is restored. Please note that the same password must be supplied to successfully decrypt the string.
Please see the example tab for a demonstration of this.
The EncryptStringAscii method returns the result in ASCII format. If you need to pass the results of the EncryptString function on the command line, or use it external to your program, it is recommended that you use the ASCII version of this function.
|
|
ReadFile
|
Private
|
Reads the specified number of bytes from the file.
Using this function significantly increases the speed of processing files. The alternative to using a file buffer is reading a byte at a time from the file.
|
Overview of Total Visual SourceBook
The source code in Total Visual
SourceBook includes modules and classes for Microsoft Access, Visual
Basic 6 (VB6), and Visual Basic for Applications (VBA) developers. Easily
add this professionally written, tested, and documented royalty-free code
into your applications to simplify your application development efforts.
Additional Resources
|
|