The openssl library (
www.openssl.org) has many
encryption algorithms and is GPL'd (or some similar
licence). It works on Linux/UNIX/*BSD and Win32.
Here is some code that I put together on Linux, it
should run on Win32 with header name changes.
It just wraps openssl's Blowfish encryption with a
bit of housekeeping in IMHO nicer function calls.
Link against libssl.
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <openssl/blowfish.h>
/************************************************** ****************
* ARGS:
* keydata == ascii text, the encryption passphrase
* keydatalen == how long keydata is
* in == the data to be encrypted
* out == the encrypted data.
* length(in) == length(out), apparently
* inlen == length of the in array
************************************************** ****************/
void bfencrypt(unsigned char *keydata, int keydatalen, char *in, char
*out, unsigned int inlen) {
BF_KEY key;
unsigned char ivec[32];
int num=0;
// set up for encryption
BF_set_key(&key, keydatalen, keydata);
memset(ivec, '\0', 32);
BF_cfb64_encrypt(in, out, inlen, &key, ivec, &num, BF_ENCRYPT);
}
void bfdecrypt(unsigned char *keydata, int keydatalen, char *in, char
*out, unsigned int inlen) {
BF_KEY key;
unsigned char ivec[32];
int num=0;
// set up for decryption
BF_set_key(&key, keydatalen, keydata);
memset(ivec, '\0', 32);
BF_cfb64_encrypt(in, out, inlen, &key, ivec, &num, BF_DECRYPT);
}
"Spikinsson" <> wrote in message news:<7DiPa.14437$>...
> I'm looking for a good decrypt/encrypt function, all I want is a function in this form:
>
> char* encrypt(char* normal)
< ...snip... >