MCPcopy Create free account
hub / github.com/CesiumGS/cesium-native / encodeBase64

Function encodeBase64

CesiumClientCommon/src/OAuth2PKCE.cpp:69–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

67namespace {
68#ifndef __EMSCRIPTEN__
69std::string encodeBase64(const std::vector<uint8_t>& bytes) {
70 const size_t count = modp_b64_encode_len(bytes.size());
71 std::string result(count, 0);
72 const size_t actualLength = modp_b64_encode(
73 result.data(),
74 reinterpret_cast<const char*>(bytes.data()),
75 bytes.size());
76 result.resize(actualLength);
77
78 // Convert to a URL-friendly form of Base64 according to the algorithm
79 // in [RFC7636 Appendix A](https://tools.ietf.org/html/rfc7636#appendix-A)
80 const size_t firstPaddingIndex = result.find('=');
81 if (firstPaddingIndex != std::string::npos) {
82 result.erase(result.begin() + ptrdiff_t(firstPaddingIndex), result.end());
83 }
84 std::replace(result.begin(), result.end(), '+', '-');
85 std::replace(result.begin(), result.end(), '/', '_');
86
87 return result;
88}
89
90std::string createSuccessHtml(const std::string& applicationName) {
91 return fmt::format(

Callers 1

authorizeMethod · 0.70

Calls 4

sizeMethod · 0.45
dataMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected