MCPcopy Create free account
hub / github.com/dfranx/SHADERed / base64_decode

Function base64_decode

src/SHADERed/Objects/WebAPI.cpp:304–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302 return (isalnum(c) || (c == '+') || (c == '/'));
303 }
304 std::string base64_decode(std::string const& encoded_string)
305 {
306 int in_len = encoded_string.size();
307 int i = 0;
308 int j = 0;
309 int in_ = 0;
310 unsigned char char_array_4[4], char_array_3[3];
311 std::string ret;
312
313 while (in_len-- && (encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
314 char_array_4[i++] = encoded_string[in_];
315 in_++;
316 if (i == 4) {
317 for (i = 0; i < 4; i++)
318 char_array_4[i] = base64_chars.find(char_array_4[i]);
319
320 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
321 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
322 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
323
324 for (i = 0; (i < 3); i++)
325 ret += char_array_3[i];
326 i = 0;
327 }
328 }
329
330 if (i) {
331 for (j = i; j < 4; j++)
332 char_array_4[j] = 0;
333
334 for (j = 0; j < 4; j++)
335 char_array_4[j] = base64_chars.find(char_array_4[j]);
336
337 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
338 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
339 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
340
341 for (j = 0; (j < i - 1); j++)
342 ret += char_array_3[j];
343 }
344
345 return ret;
346 }
347
348
349 WebAPI::WebAPI()

Callers 1

DecodeThumbnailMethod · 0.85

Calls 3

is_base64Function · 0.85
findMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected