Fnv1aHash64

Namespace: SnowBank.IO.Hashing · class

Helper for computing 64-bits FNV-1a hashes (aka "Alternative" Fowler–Noll–Vo)

Methods

Continue

static ulong Continue(ulong hash, byte[] bytes)

Continues computing the 64-bits FNV-1a hash on an additional chunk of data

  • hash — Hash computed for all previous chunks, or the initial seed (FNV1_64_OFFSET_BASIS) if this is the first chunk.
  • bytes — New chunk of bytes to process

Returns: Updated FNV-1a 64-bit hash that will include the additional data

static ulong Continue(ulong hash, ReadOnlySpan<byte> bytes)

Continues computing the 64-bits FNV-1a hash on an additional chunk of data

  • hash — Hash computed for all previous chunks, or the initial seed (FNV1_64_OFFSET_BASIS) if this is the first chunk.
  • bytes — New chunk of bytes to process

Returns: Updated FNV-1a 64-bit hash that will include the additional data

static ulong Continue(ulong hash, Slice bytes)

Continues computing the 64-bits FNV-1a hash on an additional chunk of data

  • hash — Hash computed for all previous chunks, or the initial seed (FNV1_64_OFFSET_BASIS) if this is the first chunk.
  • bytes — New chunk of bytes to process

Returns: Updated FNV-1a 64-bit hash that will include the additional data

ContinueUnsafe

static ulong ContinueUnsafe(ulong hash, Byte* bytes, int count)

Continues computing the 64-bits FNV-1a hash on an additional chunk of data

  • hash — Hash computed for all previous chunks, or the initial seed (FNV1_64_OFFSET_BASIS) if this is the first chunk.
  • bytes — Point to the start of the new chunk to process
  • count — Size (in bytes) of the chunk

Returns: Updated FNV-1a 64-bit hash that will include the additional data

FromBytes

static ulong FromBytes(byte[] bytes)

Computes the 64-bits FNV-1a hash of a byte array

  • bytes — Bytes to process

Returns: Corresponding FNV-1a 64-bit hash

static ulong FromBytes(ReadOnlySpan<byte> bytes)

Computes the 64-bits FNV-1a hash of a span of bytes

  • bytes — Bytes to process

Returns: Corresponding FNV-1a 64-bit hash

static ulong FromBytes(Slice bytes)

Computes the 64-bits FNV-1a hash of a Slice

  • bytes — Bytes to process

Returns: Corresponding FNV-1a 64-bit hash

FromBytesUnsafe

static ulong FromBytesUnsafe(Byte* buffer, int count)

Computes the 64-bits FNV-1a hash of a span of bytes

  • buffer — Pointer to the start of the data in memory
  • count — Size (in bytes) of the buffer

Returns: Corresponding FNV-1a 64-bit hash

FromString

static ulong FromString(string text, bool ignoreCase, Encoding encoding = null)

Computes the 64-bits FNV-1a hash of the utf-8 representation of a string

  • text — String to process
  • ignoreCase — If true, the string is converted to lowercase (invariant) before conversion to utf-8
  • encoding — Encoding used to convert the string into bytes (utf-8 by default)

Returns: Corresponding FNV-1a 64-bit hash

Fields

FNV1_64_OFFSET_BASIS

const ulong FNV1_64_OFFSET_BASIS

FNV1_64_PRIME

const ulong FNV1_64_PRIME