Fnv1Hash32

Namespace: SnowBank.IO.Hashing · class

Helper for computing 32-bits FNV-1 hashes (Fowler–Noll–Vo)

Methods

Continue

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

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

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

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

static uint Continue(uint hash, byte x)

Continues computing the 32-bits FNV-1 hash on the next byte of data

  • hash — Hash computed for all previous chunks, or the initial seed (FNV1_32_OFFSET_BASIS) if this is the first byte.
  • x — Additional byte

Returns: Updated FNV-1 32-bit hash that will include the additional byte

static uint Continue(uint hash, short x)

Continues computing the 32-bits FNV-1 hash on the next two bytes of data

  • hash — Hash computed for all previous chunks, or the initial seed (FNV1_32_OFFSET_BASIS) if this is the first byte.
  • x — Additional bytes

Returns: Updated FNV-1 32-bit hash that will include the additional bytes

static uint Continue(uint hash, ushort x)

Continues computing the 32-bits FNV-1 hash on the next two bytes of data

  • hash — Hash computed for all previous chunks, or the initial seed (FNV1_32_OFFSET_BASIS) if this is the first byte.
  • x — Additional bytes

Returns: Updated FNV-1 32-bit hash that will include the additional bytes

static uint Continue(uint hash, int x)

Continues computing the 32-bits FNV-1 hash on the next four bytes of data

  • hash — Hash computed for all previous chunks, or the initial seed (FNV1_32_OFFSET_BASIS) if this is the first byte.
  • x — Additional bytes

Returns: Updated FNV-1 32-bit hash that will include the additional bytes

static uint Continue(uint hash, uint x)

Continues computing the 32-bits FNV-1 hash on the next four bytes of data

  • hash — Hash computed for all previous chunks, or the initial seed (FNV1_32_OFFSET_BASIS) if this is the first byte.
  • x — Additional bytes

Returns: Updated FNV-1 32-bit hash that will include the additional bytes

static uint Continue(uint hash, long x)

Continues computing the 32-bits FNV-1 hash on the next eight bytes of data

  • hash — Hash computed for all previous chunks, or the initial seed (FNV1_32_OFFSET_BASIS) if this is the first byte.
  • x — Additional bytes

Returns: Updated FNV-1 32-bit hash that will include the additional bytes

static uint Continue(uint hash, ulong x)

Continues computing the 32-bits FNV-1 hash on the next eight bytes of data

  • hash — Hash computed for all previous chunks, or the initial seed (FNV1_32_OFFSET_BASIS) if this is the first byte.
  • x — Additional bytes

Returns: Updated FNV-1 32-bit hash that will include the additional bytes

static uint Continue(uint hash, byte[] buffer, int offset, int count)

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

  • hash — Hash computed for all previous chunks, or the initial seed (FNV1_32_OFFSET_BASIS) if this is the first chunk.
  • buffer — Backing store for the buffer that contains the bytes to process
  • offset — Offset of the first byte to process
  • count — Number of bytes to process

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

FromBytes

static uint FromBytes(byte[] bytes)

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

  • bytes — Bytes to process

Returns: Corresponding FNV-1 32-bit hash

static uint FromBytes(uint seed, byte[] bytes)

Computes the 32-bits FNV-1 hash of a byte array, with a custom initial seed

  • seed — Initial seed (0 for default)
  • bytes — Bytes to process

Returns: Corresponding FNV-1 32-bit hash

static uint FromBytes(byte[] bytes, int offset, int count)

Computes the 32-bits FNV-1 hash of a byte array segment, with a custom initial seed

  • bytes — Buffer containing the data to hash
  • offset — Starting offset in the buffer
  • count — Number of bytes of the buffer to hash

Returns: Hash of the buffer section

FromChars

static uint FromChars(char[] buffer, int offset, int count, Encoding encoding = null)

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

Returns: Corresponding FNV-1 32-bit hash

FromString

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

Computes the 32-bits FNV-1 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-1 32-bit hash

Fields

FNV1_32_OFFSET_BASIS

const uint FNV1_32_OFFSET_BASIS

FNV1_32_PRIME

const uint FNV1_32_PRIME