Options
All
  • Public
  • Public/Protected
  • All
Menu

External module hash

Different hash algorithms

Refferences:

import { fnv1a32, murmur2_32, murmur3_32, sum32 } from '@pencroff/ts-algorithms/dist/algorithm/hash';
const res = fnv1a32('Abc!'); // 157309246

Index

Type aliases

StringHash32Fn

StringHash32Fn: function

Non crypto hash function implementation

Type declaration

    • (value: string, prevValue?: number): number
    • Parameters

      • value: string
      • Optional prevValue: number

      Returns number

Functions

fnv1a32

  • fnv1a32(v?: string, prevRes?: number): number
  • FNV1a non-cryptographic hash function - 32 bit (MAX 2^32)

    Reference

    Parameters

    • Default value v: string = ""
    • Default value prevRes: number = 0

    Returns number

murmur2_32

  • murmur2_32(v?: string, prevRes?: number): number
  • MurmurHash2 non-cryptographic hash function - 32 bits, supports unicode

    Reference

    Parameters

    • Default value v: string = ""
    • Default value prevRes: number = 0

    Returns number

murmur3_32

  • murmur3_32(v?: string, prevRes?: number): number
  • MurmurHash3 non-cryptographic hash function - 32 bits, supports unicode

    Reference

    Parameters

    • Default value v: string = ""
    • Default value prevRes: number = 0

    Returns number

sum32

  • sum32(v?: string, prevRes?: number): number
  • Sum all characters bytes in string (MAX 2^32)

    Parameters

    • Default value v: string = ""
    • Default value prevRes: number = 0

    Returns number