I need to encrypt small data elements. These elements run from about 16 to 64 bytes in size. It would be really handy if the encrypted size were the same as the original size. However, if it can't be I do need to be able to predict the encrypted size in advance. Digging around through openssl I came up with the following approach:

#include <stdio.h>
#include <openssl/rc4.h>

RC4_KEY key;
char buf[1000];
char out[2000];

int main (int argc, char *argv[])
        int size, i;

        size = strlen (argv[2]);
        RC4_set_key (&key, size, argv[2]);

        RC4 (&key, strlen(argv[1]), argv[1], out);
        printf ("%s", out);


Where the first arg is the value and the second is the key. It seems to work but I don't know if this is the best algorithm to use or if there is a better approach. Thanks,

-- Doug

To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-questions" in the body of the message
  • QPopper Gannater János
    • Doug Hardie

Reply via email to