Created
February 26, 2014 22:11
-
-
Save alejolp/9239685 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <openssl/bio.h> | |
#include <openssl/evp.h> | |
void base64calc(const unsigned char* msg, size_t msgsize, char* out, size_t outsize) { | |
BIO *bio, *b64, *mem; | |
// Shit, this base64 thing with openssl was hard to get right. | |
b64 = BIO_new(BIO_f_base64()); | |
// No b64 newlines. | |
BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL); | |
mem = BIO_new(BIO_s_mem()); | |
bio = BIO_push(b64, mem); | |
BIO_write(bio, msg, msgsize); | |
BIO_flush(bio); | |
BIO_gets(mem, out, outsize); | |
BIO_free_all(bio); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for you gist...
I copy and compile it, but it throws me deprecation warnings:
Do you have some idea to fix/avoid these warnings?