DotNext by .NET Foundation and Contributors

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

 Base64Encoder

public struct Base64Encoder : IResettable
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 = 1610612731

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

public ReadOnlySpan<byte> BufferedData { get; }

Gets the buffered data.

public bool HasBufferedData { get; }

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

public static IAsyncEnumerable<ReadOnlyMemory<char>> EncodeToUtf16Async(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 MemoryOwner<char> EncodeToUtf16(ReadOnlySpan<byte> bytes, MemoryAllocator<char> allocator = null, bool flush = false)

Encodes a block of bytes to base64-encoded characters.

public void EncodeToUtf16(ReadOnlySpan<byte> bytes, ref BufferWriterSlim chars, bool flush = false)

Encodes a block of bytes to base64-encoded characters.

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

Encodes a block of bytes to base64-encoded 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(ReadOnlySpan<byte> bytes, ref BufferWriterSlim chars, bool flush = false)

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

public void EncodeToUtf8(ReadOnlySpan<byte> bytes, IBufferWriter<byte> chars, 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 void Reset()

Resets the internal state of the encoder.