summaryrefslogtreecommitdiff
path: root/indra/llcommon/llbase64.cpp
diff options
context:
space:
mode:
authorAndrey Lihatskiy <alihatskiy@productengine.com>2024-10-17 16:56:21 +0300
committerGitHub <noreply@github.com>2024-10-17 16:56:21 +0300
commit0ef7a9b39cf72da1211039ab22bdf8f9f6a2c984 (patch)
tree6f51ef179497265b5bff2a355471ae5dc9643ad2 /indra/llcommon/llbase64.cpp
parent9e24b300d02e5627ea0d304d412cb683ec2de3a4 (diff)
parentd3d349ae0f17a72481f30b9354b9367b1cd3b639 (diff)
Merge pull request #2856 from secondlife/marchcat/c-develop
Develop → Maint C sync
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 dbbbec9813..b8185a0c84 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;
+}
+