|
a/src/utils/base64.cpp |
|
b/src/utils/base64.cpp |
|
... |
|
... |
215 |
unsigned char input[3];
|
215 |
unsigned char input[3];
|
216 |
unsigned char output[4];
|
216 |
unsigned char output[4];
|
217 |
|
217 |
|
218 |
out.clear();
|
218 |
out.clear();
|
219 |
|
219 |
|
220 |
int srclength = in.length();
|
220 |
string::size_type srclength = in.length();
|
221 |
int sidx = 0;
|
221 |
int sidx = 0;
|
222 |
while (2 < srclength) {
|
222 |
while (2 < srclength) {
|
223 |
input[0] = in[sidx++];
|
223 |
input[0] = in[sidx++];
|
224 |
input[1] = in[sidx++];
|
224 |
input[1] = in[sidx++];
|
225 |
input[2] = in[sidx++];
|
225 |
input[2] = in[sidx++];
|
|
... |
|
... |
242 |
|
242 |
|
243 |
/* Now we worry about padding. */
|
243 |
/* Now we worry about padding. */
|
244 |
if (0 != srclength) {
|
244 |
if (0 != srclength) {
|
245 |
/* Get what's left. */
|
245 |
/* Get what's left. */
|
246 |
input[0] = input[1] = input[2] = '\0';
|
246 |
input[0] = input[1] = input[2] = '\0';
|
247 |
for (int i = 0; i < srclength; i++)
|
247 |
for (string::size_type i = 0; i < srclength; i++)
|
248 |
input[i] = in[sidx++];
|
248 |
input[i] = in[sidx++];
|
249 |
|
249 |
|
250 |
output[0] = input[0] >> 2;
|
250 |
output[0] = input[0] >> 2;
|
251 |
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
|
251 |
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
|
252 |
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
|
252 |
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
|