summaryrefslogtreecommitdiff
path: root/indra/llcommon/llbase64.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/llcommon/llbase64.cpp')
-rw-r--r--indra/llcommon/llbase64.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/indra/llcommon/llbase64.cpp b/indra/llcommon/llbase64.cpp
index bb85fe32a3..6591e9b49a 100644
--- a/indra/llcommon/llbase64.cpp
+++ b/indra/llcommon/llbase64.cpp
@@ -59,3 +59,19 @@ std::string LLBase64::encode(const U8* input, size_t input_size)
return output;
}
+std::string LLBase64::decodeAsString(const std::string &input)
+{
+ int b64_buffer_length = apr_base64_decode_len(input.c_str());
+ char* b64_buffer = new char[b64_buffer_length];
+
+ // This is faster than apr_base64_encode() if you know
+ // you're not on an EBCDIC machine. Also, the output is
+ // null terminated, even though the documentation doesn't
+ // specify. See apr_base64.c for details. JC
+ b64_buffer_length = apr_base64_decode(b64_buffer, input.c_str());
+ std::string res;
+ res.assign(b64_buffer);
+ delete[] b64_buffer;
+ return res;
+}
+