# HG changeset patch # User Sebastien Jodogne # Date 1348651265 -7200 # Node ID de8a5329b069213339a4e5057a6eac0f3337de48 # Parent ebce15865cce1278248f405be25c79af51fb9c10 fix of base64 diff -r ebce15865cce -r de8a5329b069 Core/Toolbox.cpp --- a/Core/Toolbox.cpp Wed Sep 26 09:26:50 2012 +0200 +++ b/Core/Toolbox.cpp Wed Sep 26 11:21:05 2012 +0200 @@ -343,7 +343,7 @@ std::string Toolbox::EncodeBase64(const std::string& data) { - return base64_encode(data.c_str()); + return base64_encode(data); } } diff -r ebce15865cce -r de8a5329b069 Resources/base64/base64.cpp --- a/Resources/base64/base64.cpp Wed Sep 26 09:26:50 2012 +0200 +++ b/Resources/base64/base64.cpp Wed Sep 26 11:21:05 2012 +0200 @@ -38,9 +38,11 @@ return (isalnum(c) || (c == '+') || (c == '/')); } -std::string base64_encode(const char* stringToEncode) { - unsigned char const* bytes_to_encode = reinterpret_cast(stringToEncode); - unsigned int in_len = strlen(stringToEncode); +std::string base64_encode(const std::string& stringToEncode) +{ + const unsigned char* bytes_to_encode = reinterpret_cast + (stringToEncode.size() > 0 ? &stringToEncode[0] : NULL); + unsigned int in_len = stringToEncode.size(); std::string ret; int i = 0; @@ -81,8 +83,8 @@ } return ret; +} -} std::string base64_decode(const std::string& encoded_string) { int in_len = encoded_string.size(); diff -r ebce15865cce -r de8a5329b069 Resources/base64/base64.h --- a/Resources/base64/base64.h Wed Sep 26 09:26:50 2012 +0200 +++ b/Resources/base64/base64.h Wed Sep 26 11:21:05 2012 +0200 @@ -1,4 +1,4 @@ #include -std::string base64_encode(const char* stringToEncode); +std::string base64_encode(const std::string& stringToEncode); std::string base64_decode(const std::string& s);