我使用下面的代码,我使用内存缓冲区中的 BIO_read 进行 base64 解码。有时BIO_read
返回0
size 参数。我还不明白为什么会发生这种情况。有任何想法吗?
static std::vector<unsigned char> base64_decode(void *input, int length)
{
std::vector<unsigned char> result(length, 0);
BIO *b64, *bmem;
b64 = BIO_new(BIO_f_base64());
bmem = BIO_new_mem_buf(input, length);
bmem = BIO_push(b64, bmem);
int size = BIO_read(bmem, &result[0], length);
if (size == 0)
fprintf(stderr, "Problem\n");
result.resize(size);
BIO_free_all(bmem);
return result;
}