Skip to content

About

Fast Xor for .NET.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Repository files navigation

FastXor NuGet

Fast Xor for .NET

SIMD-accelerated XOR operations on byte spans for up to 32x speedup.

  • Uses System.Numerics.Tensors.TensorPrimitives.Xor for high-performance platform-optimized vectorized XOR.
  • Target: .NET 10+.
  • Speedup: Performance depends on runtime and CPU SIMD support.
  • Safety: Methods are static, stateless, and safe for concurrent use.
  • All spans must have equal length (ArgumentOutOfRangeException is thrown otherwise).

Installation (NuGet):

dotnet add package FastXor

Methods:

///Xor's left byte span into dest byte span.
public static void Xor(Span<byte> dest, ReadOnlySpan<byte> left)

///Xor's left and right byte spans into dest byte span.
public static void Xor(Span<byte> dest, ReadOnlySpan<byte> left, ReadOnlySpan<byte> right)

Example:

// using SecurityDriven;

// In-place XOR: dest ^= left (lengths must match)
Span<byte> dest = stackalloc byte[64];
ReadOnlySpan<byte> left = new byte[64];
FastXor.Xor(dest, left);

// Two-source XOR: dest = left ^ right (all lengths must match)
ReadOnlySpan<byte> right = new byte[64];
FastXor.Xor(dest, left, right);

About

Fast Xor for .NET.

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages