Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Encryption and Decryption with ATL

0.00/5 (No votes)
9 Jun 2003 1  
WTL and console applications based on ATL implementation of Cryptography

Sample Image - EncryptionDecryption.gif

Introduction

After reading ATL Server - Web Application/Web Service by Leon Finker I made a simple application to illustrate an ATL implementation of Cryptography. One is a command line tool, second is a WTL dialog (see above).

Background

Please read Cryptographic Reference part of ATL Server Library Reference in MSDN Library.

Using the code

There are three projects, EncryptionDecryption which contains classes to store parameters, to parse command line and to encrypt/decrypt files based on provided parameters. Console, the console application and Window, the WTL application with GUI.

Parameters are stored in the class Parameters with simple getters/setters and one important method, IsValid which checks Parameters consistency. Only valid Parameters can be processed by the next class Engine with method DoJob. Errors are managed by class Error which simply stores error codes and messages. Class Parser (required in console application only) parses the command line arguments. The WTL project, dialog based, has an additional class, FileEdit, the file-drop target. Users do not have to type filenames or choose files from the open-file dialog, he/she can drag the file from Explorer and drop it on the edit control.

For the console application these steps are required:
  • Create Error, Parameters and Parser instances
  • Parse command line (ParseCommandLine method)
  • Check parameters (IsValid method)
  • Create Engine instance and call its DoJob method.
For the window application these steps are required:
  • Make Parameters as member of window dialog class
  • Create Error instance and set parameters read from dialog controls
  • Check parameters (IsValid method)
  • Create Engine instance and call it DoJob method.

As I said earlier, class FileEdit supports drag-drop files. But for users who use browse button, window dialog class keeps track of chosen folders. Two CString fields: m_szInputFileDir and m_szOutputFileDir remember paths during browsing.

There is possible to parametrize other things, like:
  • Cryptographic Provider Type in Initialize method of CCryptProv class
  • container name in Initialize method of CCryptProv class
  • import/export cryptographic key
  • and more...

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here