mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
correct required base64 buffer size
This commit is contained in:
parent
f3b277aeef
commit
e90baf3ca6
14
Base.cpp
14
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user