-
借助BIO对象是OpenSSL中的一种抽象,用于处理各种类型的输入/输出,如文件、套接字、内存等。
-
BIO链,通过BIO_push()接口,可以实现b64对象和需要编解码的字符串的链接。
– BIO_read(),使字符串经过B64解码,读出;
– BIO_write(),使字符串经过B64编码,写入BIO_mem, 再从memory读出。
注:BIO_write()后一定需要调用BIO_flush(),将BIO_mem 内部缓冲区的数据都写出去。
下面是自己调试的代码:
#include <openssl/evp.h>
#include <openssl/buffer.h>
#include <string.h>
#include <string>
#include <iostream>
using namespace std;
std::string base64_decode(const std::string& input) {
BIO* b64 = BIO_new<