Table of Contents

Class CryptographicOperationsCompat

Namespace
FishMMO.Shared
Assembly
FishMMO-SharedUtility.dll

Cross-platform replacement for ZeroMemory(Span<byte>) that works on Unity IL2CPP, Mono, and .NET Core/.NET 8+.

public static class CryptographicOperationsCompat
Inheritance
CryptographicOperationsCompat
Inherited Members

Remarks

ZeroMemory(Span<byte>) was added in .NET Core 3.0 and is NOT available in Unity's IL2CPP runtime (which targets .NET Standard 2.0). This polyfill uses Span<T>.Clear() on IL2CPP and delegates to the BCL method elsewhere.

Methods

FixedTimeEquals(byte[], byte[])

Determines the equality of two byte sequences in constant time.

public static bool FixedTimeEquals(byte[] left, byte[] right)

Parameters

left byte[]
right byte[]

Returns

bool

FixedTimeEquals(ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Determines the equality of two read-only byte spans in constant time.

public static bool FixedTimeEquals(ReadOnlySpan<byte> left, ReadOnlySpan<byte> right)

Parameters

left ReadOnlySpan<byte>
right ReadOnlySpan<byte>

Returns

bool

ZeroMemory(byte[])

Fills the provided buffer with zeros.

public static void ZeroMemory(byte[] buffer)

Parameters

buffer byte[]

ZeroMemory(byte[], int, int)

Fills a segment of the provided buffer with zeros.

public static void ZeroMemory(byte[] buffer, int offset, int length)

Parameters

buffer byte[]
offset int
length int

ZeroMemory(Span<byte>)

Fills the provided span with zeros.

public static void ZeroMemory(Span<byte> span)

Parameters

span Span<byte>