From e90baf3ca6ee30d21861c1541ffb0b57b97b3894 Mon Sep 17 00:00:00 2001 From: orignal Date: Sun, 7 Feb 2016 21:35:06 -0500 Subject: [PATCH] correct required base64 buffer size --- Base.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Base.cpp b/Base.cpp index f5144eda..1479d62f 100644 --- a/Base.cpp +++ b/Base.cpp @@ -190,6 +190,13 @@ namespace data return outCount; } + size_t Base64EncodingBufferSize (const size_t input_size) + { + auto d = div (input_size, 3); + if (d.rem) d.quot++; + return 4*d.quot; + } + /* * * iT64 @@ -328,13 +335,6 @@ namespace data return 0; } } - - // from https://stackoverflow.com/questions/1533113/calculate-the-size-to-a-base-64-encoded-message - size_t Base64EncodingBufferSize(const size_t input_size) { - const size_t code_size = ((input_size * 4) / 3); - const size_t padding_size = (input_size % 3) ? (3 - (input_size % 3)) : 0; - return code_size + padding_size; - } } }