MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / Decode

Method Decode

KBotExt/base64.h:62–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60 }
61
62 std::string Decode(const std::string& encoded_string)
63 {
64 size_t in_len = encoded_string.size();
65 size_t i = 0;
66 int in = 0;
67 unsigned char char_array_4[4], char_array_3[3];
68 std::string ret;
69
70 while (in_len-- && encoded_string[in] != '=' && is_base64(encoded_string[in]))
71 {
72 char_array_4[i++] = encoded_string[in];
73 in++;
74 if (i == 4)
75 {
76 for (i = 0; i < 4; i++)
77 char_array_4[i] = static_cast<unsigned char>(base64_chars.find(char_array_4[i]));
78
79 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
80 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
81 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
82
83 for (i = 0; i < 3; i++)
84 ret += char_array_3[i];
85 i = 0;
86 }
87 }
88
89 if (i)
90 {
91 size_t j;
92 for (j = i; j < 4; j++)
93 char_array_4[j] = 0;
94
95 for (j = 0; j < 4; j++)
96 char_array_4[j] = static_cast<unsigned char>(base64_chars.find(char_array_4[j]));
97
98 char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
99 char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
100 char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
101
102 for (j = 0; j < i - 1; j++)
103 ret += char_array_3[j];
104 }
105
106 return ret;
107 }
108};

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected