Click here to Skip to main content
Click here to Skip to main content

Encryption and Decryption with ATL

By , 9 Jun 2003
Rate this:
Please Sign up or sign in to vote.

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

About the Author

ryszarddrozd
Web Developer
Poland Poland
No Biography provided

Comments and Discussions

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

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

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

| Advertise | Privacy | Mobile
Web02 | 2.8.140421.2 | Last Updated 10 Jun 2003
Article Copyright 2003 by ryszarddrozd
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid