dave wrote:
Hi,

I am very new at this. I want to encrypt a string with des3, change it to base64
and put it into a buffer. I have found code in the man pages which seems to
accomplish this execept that it gets written into a file, in this case results.dat.
I would really appreciate it if someone could indicate how to modify this code
so that it puts the output string into a buffer.
...
    b64 = BIO_new(BIO_f_base64());
    // Here we attach the file handle for results.dat
    bio = BIO_new_fp(out, BIO_NOCLOSE);

replace this file BIO with a memory BIO (see `man BIO_s_mem`)

    bio = BIO_push(b64, bio);
    int retr=BIO_write(bio, outbuf,outlen);
    printf("bio_WRITE returns %d \n",retr);
    printf("outlen = %d \n",retr);
    BIO_flush(bio);
    BIO_free_all(bio);
          if(!EVP_CipherFinal_ex(&ctx, outbuf, &outlen))
    {
      /* Error */
      return 0;
    }
    EVP_CIPHER_CTX_cleanup(&ctx);
    return 1;
 }

Nils

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to