Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

openssl encode base64

1 réponse
Avatar
fakessh
-----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-----

1 réponse

Avatar
moebius eye
On Sat, 26 May 2012 23:24:04 +0200
fakessh wrote:

-----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-----




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 )