DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="4.8.0" />

 Base64Encoder

public struct Base64Encoder
Represents base64 encoder suitable for encoding large binary data using streaming approach.
public const int MaxBufferedDataSize = 2

Gets the maximum number of bytes that can be buffered by the encoder.

public const int MaxCharsToFlush = 4

Gets the maximum number of characters that can be produced by Flush or Flush methods.

public const int MaxInputSize = 1610612733

Gets the maximum size of the input block of bytes to encode.

public int BufferedDataSize { get; }

Gets the number of buffered bytes.

public bool HasBufferedData { get; }

Indicates that the size of the encoded data is not a multiple of 3 and the encoder.

public static IAsyncEnumerable<ReadOnlyMemory<char>> EncodeToCharsAsync(IAsyncEnumerable<ReadOnlyMemory<byte>> bytes, MemoryAllocator<char> allocator = null, CancellationToken token = default)

Encodes a sequence of bytes to characters using base64 encoding.

public static IAsyncEnumerable<ReadOnlyMemory<byte>> EncodeToUtf8Async(IAsyncEnumerable<ReadOnlyMemory<byte>> bytes, MemoryAllocator<byte> allocator = null, CancellationToken token = default)

Encodes a sequence of bytes to characters using base64 encoding.

public void EncodeToChars(ReadOnlySpan<byte> bytes, IBufferWriter<char> output, bool flush = false)

Encodes a block of bytes to base64-encoded characters.

public MemoryOwner<char> EncodeToChars(ReadOnlySpan<byte> bytes, MemoryAllocator<char> allocator = null, bool flush = false)

Encodes a block of bytes to base64-encoded characters.

public void EncodeToChars<TConsumer>(ReadOnlySpan<byte> bytes, TConsumer output, bool flush = false) where TConsumer : IReadOnlySpanConsumer<char>

Encodes a block of bytes to base64-encoded characters.

public void EncodeToChars<TArg>(ReadOnlySpan<byte> bytes, ReadOnlySpanAction<char, TArg> output, TArg arg, bool flush = false)

Encodes a block of bytes to base64-encoded characters.

public void EncodeToChars<TArg>(ReadOnlySpan<byte> bytes, method output, TArg arg, bool flush = false)

public void EncodeToChars(ReadOnlySpan<byte> bytes, TextWriter output, bool flush = false)

Encodes a block of bytes to base64-encoded characters.

public void EncodeToChars(ReadOnlySpan<byte> bytes, StringBuilder output, bool flush = false)

Encodes a block of bytes to base64-encoded characters.

public void EncodeToUtf8(ReadOnlySpan<byte> bytes, IBufferWriter<byte> output, bool flush = false)

Encodes a block of bytes to base64-encoded UTF-8 characters.

public MemoryOwner<byte> EncodeToUtf8(ReadOnlySpan<byte> bytes, MemoryAllocator<byte> allocator = null, bool flush = false)

Encodes a block of bytes to base64-encoded UTF-8 characters.

public void EncodeToUtf8<TConsumer>(ReadOnlySpan<byte> bytes, TConsumer output, bool flush = false) where TConsumer : IReadOnlySpanConsumer<byte>

Encodes a block of bytes to base64-encoded UTF-8 characters.

public void EncodeToUtf8<TArg>(ReadOnlySpan<byte> bytes, ReadOnlySpanAction<byte, TArg> output, TArg arg, bool flush = false)

Encodes a block of bytes to base64-encoded UTF-8 characters.

public void EncodeToUtf8<TArg>(ReadOnlySpan<byte> bytes, method output, TArg arg, bool flush = false)

public void EncodeToUtf8(ReadOnlySpan<byte> bytes, Stream output, bool flush = false)

Encodes a block of bytes to base64-encoded UTF-8 characters.

public int Flush(Span<char> output)

Flushes the buffered data as base64-encoded characters to the output buffer.

public int Flush(Span<byte> output)

Flushes the buffered data as base64-encoded UTF-8 characters to the output buffer.

public int GetBufferedData(Span<byte> output)

Gets the buffered data.

public void Reset()

Resets the internal state of the encoder.