Encryption and Decryption with ATL






4.44/5 (9 votes)
Jun 10, 2003
2 min read

65860

1391
WTL and console applications based on ATL implementation of Cryptography
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.
- Create
Error
,Parameters
andParser
instances - Parse command line (
ParseCommandLine
method) - Check parameters (
IsValid
method) - Create
Engine
instance and call itsDoJob
method.
- 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 itDoJob
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.
- Cryptographic Provider Type in
Initialize
method ofCCryptProv
class - container name in
Initialize
method ofCCryptProv
class - import/export cryptographic key
- and more...