MCPcopy Create free account
hub / github.com/CommE2E/comm / encode_triplet

Function encode_triplet

native/cpp/CommonCpp/Tools/Base64.cpp:41–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39 0x64, 0x64, 0x64, 0x64};
40
41std::array<char, 4> encode_triplet(uint8_t a, uint8_t b, uint8_t c) {
42 constexpr uint32_t SIX_BIT_MASK = 0b111111;
43 const uint32_t concat_bits = (a << 16) | (b << 8) | c;
44 const auto x = encode_table[(concat_bits >> 18) & SIX_BIT_MASK];
45 const auto y = encode_table[(concat_bits >> 12) & SIX_BIT_MASK];
46 const auto z = encode_table[(concat_bits >> 6) & SIX_BIT_MASK];
47 const auto w = encode_table[concat_bits & SIX_BIT_MASK];
48 return {x, y, z, w};
49}
50
51std::array<uint8_t, 3> decode_quad(char a, char b, char c, char d) {
52 constexpr uint32_t BYTE_MASK = 0xff;

Callers 1

encodeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected