Table of Contents

Class SecurePadding

Namespace
LibSodium
Assembly
LibSodium.Net.dll

Provides methods for padding and unpadding byte buffers to ensure they meet specified block sizes.

public static class SecurePadding
Inheritance
SecurePadding
Inherited Members

Methods

Pad(Span<byte>, int, int)

Pads the given buffer to the specified block size.

public static Span<byte> Pad(Span<byte> buffer, int unpaddedLen, int blockSize)

Parameters

buffer Span<byte>

The buffer to pad.

unpaddedLen int

The length of the data before padding.

blockSize int

The block size to pad to.

Returns

Span<byte>

A span of the padded buffer.

Exceptions

ArgumentException

Thrown when blockSize is less than or equal to 0 or unpaddedLen is greater than buffer length.

Unpad(Span<byte>, int)

Unpads the given buffer that was padded to a specified block size.

public static Span<byte> Unpad(Span<byte> buffer, int blockSize)

Parameters

buffer Span<byte>

The buffer to unpad.

blockSize int

The block size that was used for padding.

Returns

Span<byte>

A span of the unpadded buffer.

Exceptions

ArgumentException

Thrown when blockSize is less than or equal to 0.

LibSodiumException

Thrown when unpadding fails.