AES Encryption Using Crypto++ .lib in Visual Studio C++

This is a quick note showing how to compile, link and include a Crypto++ static library (cryptlib.lib), compile and execute a sample code that uses AES CBC to encrypt and decrypt some string data.

Compiling cryptlib.lib

Open the crypto++ solution file cryptest.sln:

Change cryptlib project runtime library to Multi-threaded and change configuration to Release x64:

Build cryptlib project. It will spit out a cryptlib.lib static library:

Including cryptlib.lib in a Project

Create a new VS project and include cryptlib.lib that you've just compiled:

Change project's runtime library to Multi-threaded - it has to use the same runtime library as cryptlib.lib:

Copy over all the header files from the crypto++ project to your project's folder like so:

Include those headers in the project by adding the folder to Include Directories list:

Copy over the below sample code to your main .cpp file and compile:

Success:

References

Last updated