(Tutorial) Writing a C++ Program with the CAPICOM Component to Encrypt and Decrypt Files
Writing a C++ Program with the CAPICOM Component to Encrypt and Decrypt Files
Introduction
The purpose of this article to try help the beginner to learn how to encrypt and
decrypt files using a symmetric key algorithm (e.g. RC2, RC4, DES,
Triple-DES, and AES) by building an application with Visual C++ that uses
the CAPICOM component. The Platform SDK redistributable ships a COM component
called CAPICOM. CAPI stands for Crypto API. When we download this component,
Capicom.dll, we must install on our machine. Because it installs by default in
the program files directory, we must traverse the CAPICOM folder on the command
line until we find the Capicom.dll in the directory listing. At that point, we
use the ‘regsvr32 Capicom.dll’ command to get a “succeeded†box. To build this
application, simply use Visual C++ Express 2005 or 2008, or use Visual Studio.
Remember to choose the Win32 Console application icon when starting the process
and to choose “empty project†in the application settings box. Copy and paste
this code, build the solution, and deploy the executable.
The source code file uses four headers that predefine methods that deal with
strings, and files that deal with strings. The template is for file I/O. And
because we are not using the Crypto API but the CAPICOM component, we must
initialize the COM library and at some point, uninitialize it. Import the
Capicom.dll. I used quotation marks after the import statement in my source code
file after I copied and pasted the DLL into the same directory as the source. It
can help to avoid file path errors when building the solution. Here is the
source code, which will be explained:- [..]
Read
full article..
Courtesy : Codeproject.com
- guru's blog
- Login or register to post comments

