Hello list, I'm new here, I'm trying to encrypt / decrypt text in a file using the rc4, the problem is that I'm not getting good results, here's what I'm doing for encryption:
#include <stdio.h> #include <stdlib.h> #include <openssl/bio.h> #include <openssl/evp.h> int main(void) { char buf[1024]; int total, len, written; BIO *file = BIO_new_file("out.bin", "w"); BIO *buffer = BIO_new(BIO_f_buffer()); BIO *cipher = BIO_new(BIO_f_cipher()); strcpy(buf, "Simple Text to Encrypt"); BIO_set_cipher(cipher, EVP_rc4(), "mysecretkey", NULL, 1); BIO_push (cipher, buffer); BIO_push (buffer, file); len = strlen(buf); written = 0; for (total = 0; total < len; total += written) { if ((written = BIO_write(cipher, buf + total, len - total)) <= 0) { if (BIO_should_retry(cipher)) { written =0; continue; } break; } } BIO_flush(cipher); BIO_free_all(cipher); } compiled it, and when executed I get a out.bin, then when I try to decrypt it it fails: $ openssl enc -d -rc4 -in out.bin -k mysecretkey bad magic number what I'm I doing wrong? maybe the -k -K -iv options? as BIO_set_cipher as well maybe? Regards and thank for your time ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager [EMAIL PROTECTED]