mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
AK: Add a public helper to count the decoded length of a Base64 string
This commit is contained in:
parent
41e14e3fc3
commit
35d8e7e63f
|
|
@ -12,10 +12,15 @@
|
|||
|
||||
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)
|
||||
{
|
||||
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(
|
||||
input.characters_without_null_termination(),
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
size_t size_required_to_decode_base64(StringView);
|
||||
|
||||
ErrorOr<ByteBuffer> decode_base64(StringView);
|
||||
ErrorOr<ByteBuffer> decode_base64url(StringView);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user