MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / base64_decode

Function base64_decode

Source/external/base64.cpp:56–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56std::string base64_decode(std::string const& encoded_string)
57{
58 int in_len = encoded_string.size();
59 int i = 0;
60 int j = 0;
61 int in_ = 0;
62 unsigned char char_array_4[4], char_array_3[3];
63 std::string ret;
64
65 while (in_len-- && (encoded_string[in_] != '=') && is_base64(encoded_string[in_])) {
66 char_array_4[i++] = encoded_string[in_]; in_++;
67 if (i == 4) {
68 for (i = 0; i < 4; i++)
69 char_array_4[i] = base64_chars.find(char_array_4[i]);
70
71 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
72 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
73 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
74
75 for (i = 0; (i < 3); i++)
76 ret += char_array_3[i];
77 i = 0;
78 }
79 }
80
81 if (i) {
82 for (j = i; j < 4; j++)
83 char_array_4[j] = 0;
84
85 for (j = 0; j < 4; j++)
86 char_array_4[j] = base64_chars.find(char_array_4[j]);
87
88 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
89 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
90 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
91
92 for (j = 0; (j < i - 1); j++) ret += char_array_3[j];
93 }
94
95 return ret;
96}

Callers 4

initMethod · 0.85
decompressLvlStrMethod · 0.85

Calls 2

is_base64Function · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected