Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

openssl encode base64

18 views
Skip to first unread message

fakessh

unread,
May 26, 2012, 5:24:04 PM5/26/12
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

bonjour les news

j ecris un petit client smtp et je suis confronter à encoder mes
donnees en base64

j utilise les fonctions standard openssl
ma fonction
https://github.com/fakessh/openprojectssl/blob/master/smtp_openssl.c

char *base64(char *input, int length)
{
BIO *bmem, *b64;
BUF_MEM *bptr;

b64 = BIO_new(BIO_f_base64());
bmem = BIO_new(BIO_s_mem());
b64 = BIO_push(b64, bmem);
BIO_write(b64, input, length);
BIO_flush(b64);
BIO_get_mem_ptr(b64, &bptr);

char *buff = (char *)malloc(bptr->length+1);
memcpy(buff, bptr->data, bptr->length);
buff[bptr->length] = 0;

BIO_free_all(b64);

return buff;
}

malgre toute l attention que j ai mis en oeuvre pour ecrire ma fonction
cela ne fonctionne pas

pouvez vous m aidez

sincerement
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/BSfQACgkQNgqL0sJiZ0JHMACcDhd2JIXhjoA3XOoxrmKh4EKU
ZxoAniTuMQ6N19lgb9dKMc5ug4EgX+2F
=QXqh
-----END PGP SIGNATURE-----

moebius eye

unread,
Jan 1, 2013, 4:21:48 PM1/1/13
to
I had to do that in one of my last projects.

It was in the context of a gtk application, so I used g_base46_encode()
as described here: ( http://developer.gnome.org/glib/2.28/glib-Base64-Encoding.html )

0 new messages