mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
AK: Add a public helper to count the decoded length of a Base64 string
This commit is contained in:
committed by
Andreas Kling
parent
41e14e3fc3
commit
35d8e7e63f
@@ -12,10 +12,15 @@
|
|||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
|
size_t size_required_to_decode_base64(StringView input)
|
||||||
|
{
|
||||||
|
return simdutf::maximal_binary_length_from_base64(input.characters_without_null_termination(), input.length());
|
||||||
|
}
|
||||||
|
|
||||||
static ErrorOr<ByteBuffer> decode_base64_impl(StringView input, simdutf::base64_options options)
|
static ErrorOr<ByteBuffer> decode_base64_impl(StringView input, simdutf::base64_options options)
|
||||||
{
|
{
|
||||||
ByteBuffer output;
|
ByteBuffer output;
|
||||||
TRY(output.try_resize(simdutf::maximal_binary_length_from_base64(input.characters_without_null_termination(), input.length())));
|
TRY(output.try_resize(size_required_to_decode_base64(input)));
|
||||||
|
|
||||||
auto result = simdutf::base64_to_binary(
|
auto result = simdutf::base64_to_binary(
|
||||||
input.characters_without_null_termination(),
|
input.characters_without_null_termination(),
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
|
size_t size_required_to_decode_base64(StringView);
|
||||||
|
|
||||||
ErrorOr<ByteBuffer> decode_base64(StringView);
|
ErrorOr<ByteBuffer> decode_base64(StringView);
|
||||||
ErrorOr<ByteBuffer> decode_base64url(StringView);
|
ErrorOr<ByteBuffer> decode_base64url(StringView);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user