MCPcopy Create free account
hub / github.com/AutoHotkey/AutoHotkey / Base64Encode

Method Base64Encode

source/Debugger.cpp:2314–2348  ·  view source on GitHub ↗

Encode base 64 data.

Source from the content-addressed store, hash-verified

2312
2313// Encode base 64 data.
2314size_t Debugger::Base64Encode(char *aBuf, const char *aInput, size_t aInputSize/* = -1*/)
2315{
2316 UINT_PTR buffer;
2317 size_t i, len = 0;
2318
2319 if (aInputSize == -1) // Direct comparison since aInputSize is unsigned.
2320 aInputSize = strlen(aInput);
2321
2322 for (i = aInputSize; i > 2; i -= 3)
2323 {
2324 buffer = (UCHAR)aInput[0] << 16 | (UCHAR)aInput[1] << 8 | (UCHAR)aInput[2]; // L39: Fixed for chars outside the range 0..127. [thanks jackieku]
2325 aInput += 3;
2326
2327 aBuf[len + 0] = BINARY_TO_BASE64_CHAR(buffer >> 18);
2328 aBuf[len + 1] = BINARY_TO_BASE64_CHAR(buffer >> 12);
2329 aBuf[len + 2] = BINARY_TO_BASE64_CHAR(buffer >> 6);
2330 aBuf[len + 3] = BINARY_TO_BASE64_CHAR(buffer);
2331 len += 4;
2332 }
2333 if (i > 0)
2334 {
2335 buffer = (UCHAR)aInput[0] << 16;
2336 if (i > 1)
2337 buffer |= (UCHAR)aInput[1] << 8;
2338 // aInput not incremented as it is not used below.
2339
2340 aBuf[len + 0] = BINARY_TO_BASE64_CHAR(buffer >> 18);
2341 aBuf[len + 1] = BINARY_TO_BASE64_CHAR(buffer >> 12);
2342 aBuf[len + 2] = (i > 1) ? BINARY_TO_BASE64_CHAR(buffer >> 6) : '=';
2343 aBuf[len + 3] = '=';
2344 len += 4;
2345 }
2346 aBuf[len] = '\0';
2347 return len;
2348}
2349
2350// Decode base 64 data. aBuf and aInput may point to the same buffer.
2351size_t Debugger::Base64Decode(char *aBuf, const char *aInput, size_t aInputSize/* = -1*/)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected