If you happen to have an older compiler, you may need to download the crypto API from Microsoft’s Web site. Older, non-Microsoft compilers may require you to generate an import library. Windows 98 includes the crypto runtime, however if you intend to deploy software on Windows 95 stations, you may need to add the crypto runtime to each station. Finally, before software that uses the crypto runtime will run correctly the first time, you must generate a default CSP and default keys. The following sections describe each of these procedures.
You can get the crypto API SDK either by free download from the Internet (at Microsoft’s developer pages) or from the latest MSDN (Microsoft Developer Network) CD-ROM.
NOTE
If you have a recent compiler, it probably already includes the WinCrypt.H header file, help files, and library files, so you will not need to download the crypto API SDK.
If you’re using a non-Microsoft compiler, you may also need to come up with import libraries (or import units, if you’re using Delphi) for the crypto API functions. If you’re lucky, your compiler vendor will have made a set of import libraries/units available on its BBS or Web site.
For Microsoft compilers, the import library will be available as part of the crypto API SDK. Also, Borland C++ 5.0 and later and C++ Builder already include the crypto API header and library.
For older Borland C/C++ compilers, it’s a simple matter to create import libraries using Implib.EXE. (Simply run implib dllname).
If you’re using Borland Pascal or Delphi (prior to version 3.0), you’ll need to create an import unit, which is simply a Pascal unit that has function prototypes specified (in Pascal), along with an implementation section that specifies which DLL each function is exported from. If you need an example of an import library, see the Delphi Windows import units, which show how this is done.
Although Windows 98 stations will already have the crypto runtime installed, older Windows 95 stations may not. To install the crypto API runtime support, you have two options:
TIP
As with any Windows API, it’s a good idea to check out Microsoft’s Web pages to be sure that there is not a more recent version of the crypto API to download.
Even if the crypto runtime is already installed on your system, chances are that you will also need to create a default CSP and a set of default keys as well, before you can make use of the crypto API functions. Fortunately, the crypto API SDK comes with a sample applet which, when run, installs these for you. Look for a file called Inituser.C. Simply compile and run this once to complete the initialization process.
At this point, you should be ready to begin using the crypto API. The Encrypt and Decrypt demos, discussed next, should get you started.