diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-01-15 01:16:34 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-01-15 01:16:34 +0300 |
commit | c3b87f283a5a99ed8bac513c516bc5a184406391 (patch) | |
tree | 78cce6c60cb82b8e191e633ec2c4fce1e1672708 /src/utils/base64.cpp | |
parent | 1b7fa30e602ae18a68153d4e5acec8e4d9ea9e33 (diff) | |
download | plus-c3b87f283a5a99ed8bac513c516bc5a184406391.tar.gz plus-c3b87f283a5a99ed8bac513c516bc5a184406391.tar.bz2 plus-c3b87f283a5a99ed8bac513c516bc5a184406391.tar.xz plus-c3b87f283a5a99ed8bac513c516bc5a184406391.zip |
add option for edit screenshot dir.
Diffstat (limited to 'src/utils/base64.cpp')
-rw-r--r-- | src/utils/base64.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/utils/base64.cpp b/src/utils/base64.cpp index 280e71ff0..f887a9e1b 100644 --- a/src/utils/base64.cpp +++ b/src/utils/base64.cpp @@ -174,3 +174,32 @@ unsigned char *php3_base64_decode(const unsigned char *restrict const string, result[k] = '\0'; return result; } + +std::string encodeBase64String(std::string value) +{ + int sz = 0; + unsigned char *str = reinterpret_cast<unsigned char*>( + const_cast<char*>(value.c_str())); + unsigned char *const buf = php3_base64_encode(str, value.size(), &sz); + if (!buf) + return std::string(); + + value = std::string(reinterpret_cast<char*>(buf), sz); + free(buf); + return value; +} + +std::string decodeBase64String(std::string value) +{ + int sz = 0; + unsigned char *str = reinterpret_cast<unsigned char*>( + const_cast<char*>(value.c_str())); + unsigned char *const buf = php3_base64_decode(str, value.size(), &sz); + + if (buf) + value = std::string(reinterpret_cast<char*>(buf), sz); + else + value.clear(); + free(buf); + return value; +} |