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

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

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