MCPcopy Create free account
hub / github.com/Snapchat/Valdi / binaryToBase64

Function binaryToBase64

libs/utils/src/utils/encoding/Base64Utils.cpp:14–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12namespace snap::utils::encoding {
13
14std::string binaryToBase64(const uint8_t* data, size_t size) {
15 size_t maxOutSize = 0;
16 if (size == 0 || EVP_EncodedLength(&maxOutSize, size) != 1 || maxOutSize == 0) {
17 return "";
18 }
19
20 std::string result(maxOutSize, '\0');
21 EVP_EncodeBlock(reinterpret_cast<uint8_t*>(result.data()), data, size);
22 result.resize(result.size() - 1); // remove the trailing \0 that EVP_EncodeBlock always writes
23 return result;
24}
25
26std::string binaryToBase64(const std::vector<uint8_t>& binary) {
27 return binaryToBase64(binary.data(), binary.size());

Callers 6

writeValueToJSONWriterFunction · 0.85
TESTFunction · 0.85
storeMethod · 0.85
onDecodeErrorMethod · 0.85
uint64ToBase64Function · 0.85

Calls 3

dataMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45

Tested by 1

TESTFunction · 0.68