Loading src/base64.cpp +4 Changes for src/base64.cpp: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ void netplus::base64::clear(){ netplus::base64 & netplus::base64::operator>>(const std::vector<char> &data){ std::copy(data.begin(),data.end(),std::back_inserter(_encoded)); int val=0, valb=-8; for (char c : data) { if (basis_64.find(c) == std::string::npos) Loading @@ -65,6 +66,7 @@ netplus::base64 & netplus::base64::operator>>(const std::vector<char> &data){ } netplus::base64 &netplus::base64::operator>>(const std::string &data){ std::copy(data.begin(),data.end(),std::back_inserter(_encoded)); int val=0, valb=-8; for (char c : data) { if (basis_64.find(c) == std::string::npos) Loading @@ -80,6 +82,7 @@ netplus::base64 &netplus::base64::operator>>(const std::string &data){ } netplus::base64 &netplus::base64::operator << (const std::vector<char> &data){ std::copy(data.begin(),data.end(),std::back_inserter(_decoded)); size_t missing = 0; size_t ret_size = data.size(); Loading Loading @@ -128,6 +131,7 @@ netplus::base64 &netplus::base64::operator << (const std::vector<char> &data){ } netplus::base64 &netplus::base64::operator << (const std::string &data){ std::copy(data.begin(),data.end(),std::back_inserter(_decoded)); size_t missing = 0; size_t ret_size = data.size(); Loading src/base64.h −94 Changes for src/base64.h: 0 added lines, 94 removed lines. Original line number Diff line number Diff line Loading @@ -53,97 +53,3 @@ namespace netplus { std::vector<char> _decoded; }; }; // inline size_t Decodelen(const char* bufcoded) { // size_t nbytesdecoded; // const unsigned char* bufin; // int nprbytes; // // bufin = (const unsigned char*)bufcoded; // while (pr2six[*(bufin++)] <= 63); // // nprbytes = (bufin - (const unsigned char*)bufcoded) - 1; // nbytesdecoded = ((nprbytes + 3) / 4) * 3; // // return nbytesdecoded + 1; // } // // inline size_t Decode(char* bufplain, const char* bufcoded) { // size_t nbytesdecoded; // const unsigned char* bufin; // unsigned char* bufout; // int nprbytes; // // bufin = (const unsigned char*)bufcoded; // while (pr2six[*(bufin++)] <= 63); // nprbytes = (bufin - (const unsigned char*)bufcoded) - 1; // nbytesdecoded = ((nprbytes + 3) / 4) * 3; // // bufout = (unsigned char*)bufplain; // bufin = (const unsigned char*)bufcoded; // // while (nprbytes > 4) { // *(bufout++) = // (unsigned char)(pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4); // *(bufout++) = // (unsigned char)(pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2); // *(bufout++) = // (unsigned char)(pr2six[bufin[2]] << 6 | pr2six[bufin[3]]); // bufin += 4; // nprbytes -= 4; // } // // /* Note: (nprbytes == 1) would be an error, so just ingore that case */ // if (nprbytes > 1) { // *(bufout++) = // (unsigned char)(pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4); // } // if (nprbytes > 2) { // *(bufout++) = // (unsigned char)(pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2); // } // if (nprbytes > 3) { // *(bufout++) = // (unsigned char)(pr2six[bufin[2]] << 6 | pr2six[bufin[3]]); // } // // *(bufout++) = '\0'; // nbytesdecoded -= (4 - nprbytes) & 3; // return nbytesdecoded; // } // // inline size_t Encodelen(size_t len) { // return ((len + 2) / 3 * 4) + 1; // } // // size_t inline Encode(char* encoded, const char* string, size_t len) { // size_t i = 0; // char* p; // // p = encoded; // for (i = 0; i < len - 2; i += 3) { // *p++ = basis_64[(string[i] >> 2) & 0x3F]; // *p++ = basis_64[((string[i] & 0x3) << 4) | // ((size_t)(string[i + 1] & 0xF0) >> 4)]; // *p++ = basis_64[((string[i + 1] & 0xF) << 2) | // ((size_t)(string[i + 2] & 0xC0) >> 6)]; // *p++ = basis_64[string[i + 2] & 0x3F]; // } // if (i < len) { // *p++ = basis_64[(string[i] >> 2) & 0x3F]; // if (i == (len - 1)) { // *p++ = basis_64[((string[i] & 0x3) << 4)]; // *p++ = '='; // } // else { // *p++ = basis_64[((string[i] & 0x3) << 4) | // ((size_t)(string[i + 1] & 0xF0) >> 4)]; // *p++ = basis_64[((string[i + 1] & 0xF) << 2)]; // } // *p++ = '='; // } // // *p++ = '\0'; // return p - encoded; // } // }; test/base64.cpp +7 −7 Changes for test/base64.cpp: 7 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -30,15 +30,15 @@ #include "../src/base64.h" int main(int argc,char *argv[]){ netplus::base64 base; netplus::base64 enc,dec; base << argv[1]; base >> base.encoded(); enc << argv[1]; dec >> enc.encoded(); const std::vector<char> &enc=base.encoded(); const std::vector<char> &dec=base.decoded(); const std::vector<char> &encdata=enc.encoded(); const std::vector<char> &decdata=dec.decoded(); std::cout.write(enc.data(),enc.size())<< std::endl; std::cout.write(encdata.data(),encdata.size())<< std::endl; std::cout.write(dec.data(),dec.size())<< std::endl; std::cout.write(decdata.data(),decdata.size())<< std::endl; } Loading
src/base64.cpp +4 Changes for src/base64.cpp: 4 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -50,6 +50,7 @@ void netplus::base64::clear(){ netplus::base64 & netplus::base64::operator>>(const std::vector<char> &data){ std::copy(data.begin(),data.end(),std::back_inserter(_encoded)); int val=0, valb=-8; for (char c : data) { if (basis_64.find(c) == std::string::npos) Loading @@ -65,6 +66,7 @@ netplus::base64 & netplus::base64::operator>>(const std::vector<char> &data){ } netplus::base64 &netplus::base64::operator>>(const std::string &data){ std::copy(data.begin(),data.end(),std::back_inserter(_encoded)); int val=0, valb=-8; for (char c : data) { if (basis_64.find(c) == std::string::npos) Loading @@ -80,6 +82,7 @@ netplus::base64 &netplus::base64::operator>>(const std::string &data){ } netplus::base64 &netplus::base64::operator << (const std::vector<char> &data){ std::copy(data.begin(),data.end(),std::back_inserter(_decoded)); size_t missing = 0; size_t ret_size = data.size(); Loading Loading @@ -128,6 +131,7 @@ netplus::base64 &netplus::base64::operator << (const std::vector<char> &data){ } netplus::base64 &netplus::base64::operator << (const std::string &data){ std::copy(data.begin(),data.end(),std::back_inserter(_decoded)); size_t missing = 0; size_t ret_size = data.size(); Loading
src/base64.h −94 Changes for src/base64.h: 0 added lines, 94 removed lines. Original line number Diff line number Diff line Loading @@ -53,97 +53,3 @@ namespace netplus { std::vector<char> _decoded; }; }; // inline size_t Decodelen(const char* bufcoded) { // size_t nbytesdecoded; // const unsigned char* bufin; // int nprbytes; // // bufin = (const unsigned char*)bufcoded; // while (pr2six[*(bufin++)] <= 63); // // nprbytes = (bufin - (const unsigned char*)bufcoded) - 1; // nbytesdecoded = ((nprbytes + 3) / 4) * 3; // // return nbytesdecoded + 1; // } // // inline size_t Decode(char* bufplain, const char* bufcoded) { // size_t nbytesdecoded; // const unsigned char* bufin; // unsigned char* bufout; // int nprbytes; // // bufin = (const unsigned char*)bufcoded; // while (pr2six[*(bufin++)] <= 63); // nprbytes = (bufin - (const unsigned char*)bufcoded) - 1; // nbytesdecoded = ((nprbytes + 3) / 4) * 3; // // bufout = (unsigned char*)bufplain; // bufin = (const unsigned char*)bufcoded; // // while (nprbytes > 4) { // *(bufout++) = // (unsigned char)(pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4); // *(bufout++) = // (unsigned char)(pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2); // *(bufout++) = // (unsigned char)(pr2six[bufin[2]] << 6 | pr2six[bufin[3]]); // bufin += 4; // nprbytes -= 4; // } // // /* Note: (nprbytes == 1) would be an error, so just ingore that case */ // if (nprbytes > 1) { // *(bufout++) = // (unsigned char)(pr2six[*bufin] << 2 | pr2six[bufin[1]] >> 4); // } // if (nprbytes > 2) { // *(bufout++) = // (unsigned char)(pr2six[bufin[1]] << 4 | pr2six[bufin[2]] >> 2); // } // if (nprbytes > 3) { // *(bufout++) = // (unsigned char)(pr2six[bufin[2]] << 6 | pr2six[bufin[3]]); // } // // *(bufout++) = '\0'; // nbytesdecoded -= (4 - nprbytes) & 3; // return nbytesdecoded; // } // // inline size_t Encodelen(size_t len) { // return ((len + 2) / 3 * 4) + 1; // } // // size_t inline Encode(char* encoded, const char* string, size_t len) { // size_t i = 0; // char* p; // // p = encoded; // for (i = 0; i < len - 2; i += 3) { // *p++ = basis_64[(string[i] >> 2) & 0x3F]; // *p++ = basis_64[((string[i] & 0x3) << 4) | // ((size_t)(string[i + 1] & 0xF0) >> 4)]; // *p++ = basis_64[((string[i + 1] & 0xF) << 2) | // ((size_t)(string[i + 2] & 0xC0) >> 6)]; // *p++ = basis_64[string[i + 2] & 0x3F]; // } // if (i < len) { // *p++ = basis_64[(string[i] >> 2) & 0x3F]; // if (i == (len - 1)) { // *p++ = basis_64[((string[i] & 0x3) << 4)]; // *p++ = '='; // } // else { // *p++ = basis_64[((string[i] & 0x3) << 4) | // ((size_t)(string[i + 1] & 0xF0) >> 4)]; // *p++ = basis_64[((string[i + 1] & 0xF) << 2)]; // } // *p++ = '='; // } // // *p++ = '\0'; // return p - encoded; // } // };
test/base64.cpp +7 −7 Changes for test/base64.cpp: 7 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -30,15 +30,15 @@ #include "../src/base64.h" int main(int argc,char *argv[]){ netplus::base64 base; netplus::base64 enc,dec; base << argv[1]; base >> base.encoded(); enc << argv[1]; dec >> enc.encoded(); const std::vector<char> &enc=base.encoded(); const std::vector<char> &dec=base.decoded(); const std::vector<char> &encdata=enc.encoded(); const std::vector<char> &decdata=dec.decoded(); std::cout.write(enc.data(),enc.size())<< std::endl; std::cout.write(encdata.data(),encdata.size())<< std::endl; std::cout.write(dec.data(),dec.size())<< std::endl; std::cout.write(decdata.data(),decdata.size())<< std::endl; }