MCPcopy Create free account
hub / github.com/allanrbo/filesremote / encodeBase64

Function encodeBase64

src/string.cpp:36–44  ·  view source on GitHub ↗

Based on https://stackoverflow.com/a/63711162/40645

Source from the content-addressed store, hash-verified

34
35// Based on https://stackoverflow.com/a/63711162/40645
36string encodeBase64(const unsigned char *input, int n) {
37 const auto predicted_len = 4 * ((n + 2) / 3); // predict output size
38 const auto output_buffer{make_unique<char[]>(predicted_len + 1)};
39 const auto output_len = EVP_EncodeBlock(reinterpret_cast<unsigned char *>(output_buffer.get()), input, n);
40 if (predicted_len != static_cast<uint64_t>(output_len)) {
41 throw runtime_error("base64 encoding error");
42 }
43 return output_buffer.get();
44}
45
46// Make strings, such as error strings, a little easier on the eyes.
47string PrettifySentence(string s) {

Callers 1

SftpConnectionMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected