c++ base64 编码

发布时间 2023-05-23 21:52:57作者: 空明流光
#include <iostream>
#include <string>
#include <vector>
#include <cryptopp/base64.h>
#include <cryptopp/filters.h>

std::string BinaryToBase64(const std::vector<unsigned char>& data)
{
    std::string encoded;
    CryptoPP::StringSource source(data.data(), data.size(), true,
        new CryptoPP::Base64Encoder(
            new CryptoPP::StringSink(encoded),
            false // do not append a newline
        )
    );
    return encoded;
}