|
a/src/utils/base64.cpp |
|
b/src/utils/base64.cpp |
|
... |
|
... |
89 |
|
89 |
|
90 |
bool base64_decode(const string& in, string& out)
|
90 |
bool base64_decode(const string& in, string& out)
|
91 |
{
|
91 |
{
|
92 |
int io = 0, state = 0, ch = 0;
|
92 |
int io = 0, state = 0, ch = 0;
|
93 |
unsigned int ii = 0;
|
93 |
unsigned int ii = 0;
|
94 |
out.erase();
|
94 |
out.clear();
|
95 |
size_t ilen = in.length();
|
95 |
size_t ilen = in.length();
|
96 |
out.reserve(ilen);
|
96 |
out.reserve(ilen);
|
97 |
|
97 |
|
98 |
for (ii = 0; ii < ilen; ii++) {
|
98 |
for (ii = 0; ii < ilen; ii++) {
|
99 |
ch = (unsigned char)in[ii];
|
99 |
ch = (unsigned char)in[ii];
|
|
... |
|
... |
215 |
void base64_encode(const string &in, string &out)
|
215 |
void base64_encode(const string &in, string &out)
|
216 |
{
|
216 |
{
|
217 |
unsigned char input[3];
|
217 |
unsigned char input[3];
|
218 |
unsigned char output[4];
|
218 |
unsigned char output[4];
|
219 |
|
219 |
|
220 |
out.erase();
|
220 |
out.clear();
|
221 |
|
221 |
|
222 |
int srclength = in.length();
|
222 |
int srclength = in.length();
|
223 |
int sidx = 0;
|
223 |
int sidx = 0;
|
224 |
while (2 < srclength) {
|
224 |
while (2 < srclength) {
|
225 |
input[0] = in[sidx++];
|
225 |
input[0] = in[sidx++];
|