Click here to Skip to main content
15,885,216 members
Articles / Desktop Programming / ATL
Article

Encryption and Decryption with ATL

Rate me:
Please Sign up or sign in to vote.
4.44/5 (10 votes)
9 Jun 20032 min read 65.4K   1.4K   46   4
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


Written By
Web Developer
Poland Poland
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionCan not Encode any file with software Pin
Morteza Ghasemi15-Dec-04 19:53
Morteza Ghasemi15-Dec-04 19:53 
GeneralGeneral CryptoAPI w/ATL question Pin
Doug Schmidt8-Mar-04 20:42
Doug Schmidt8-Mar-04 20:42 
Generalcan't find file atlapp.h Pin
sycamine18-Jun-03 15:59
sycamine18-Jun-03 15:59 
GeneralRe: can't find file atlapp.h Pin
Aardvark24-Jun-04 7:27
Aardvark24-Jun-04 7:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.