I see ton's of examples of this for C++ and C# but no luck with C. I'm trying to do a simple encryption of a string without referencing external DLLs. I started out trying cryptlib (just basic encryption before moving on to PGP) and with the following .c file:
#include "include/cryptlib/cryptlib.h"
void PGPEncrypt(char* input, char* output) {
CRYPT_ENVELOPE cryptEnvelope;
int bytesCopied;
cryptCreateEnvelope(&cryptEnvelope, CRYPT_UNUSED, CRYPT_FORMAT_CRYPTLIB);
// Below line makes things more efficient if you know the data size
cryptSetAttribute(cryptEnvelope, CRYPT_ENVINFO_DATASIZE, strlen(input));
// Push unencrypted, pop encrypted. 4000 is the size of output
cryptPushData(cryptEnvelope, input, strlen(input), &bytesCopied);
cryptFlushData(cryptEnvelope);
cryptPopData(cryptEnvelope, output, 4000, &bytesCopied);
cryptDestroyEnvelope(cryptEnvelope);
}
However, while compiling this worked, I realized when running the application that the cl32.lib was just a header library and required the cl32.dll file to be installed on the system. I have yet to figure out how to create a static cl32.lib file that I can include in my project that would not require the DLL. That would work, or another non-cryptlib solution.
I've also taken a look at Crypto++, but unfortunately the downloadable chm user guide is broken, and the manual is too detailed for me to follow without a guide of some kind.
I should throw out there that while I'm fairly familiar with C as a whole, most of my experience is old and in Linux, not using Visual Studio 2010 which I am doing now.
Thanks, Ben