2e: Insecure Hashing

+mug

Murmur3 scrambler.

Hashes a with the 31-bit murmur3 non-cryptographic hash algorithm, producing an atom.

Accepts

.a is a $noun.

Produces

An atom.

Source

++  mug
  ~/  %mug
  |=  a=*
  |^  ?@  a  (mum 0xcafe.babe 0x7fff a)
      =/  b  (cat 5 $(a -.a) $(a +.a))
      (mum 0xdead.beef 0xfffe b)
  ::
  ++  mum
    |=  [syd=@uxF fal=@F key=@]
    =/  wyd  (met 3 key)
    =|  i=@ud
    |-  ^-  @F
    ?:  =(8 i)  fal
    =/  haz=@F  (muk syd wyd key)
    =/  ham=@F  (mix (rsh [0 31] haz) (end [0 31] haz))
    ?.(=(0 ham) ham $(i +(i), syd +(syd)))
  --

Examples


+muk

Standard MurmurHash3.

Implementation of the 32-bit MurmurHash3 non-cryptographic hash algorithm. Takes .syd as the seed, .len as the key length in blocks of size 3, and .key as the key, producing an atom.

Accepts

.syd is an atom.

.len is an atom.

.key is an atom.

Produces

An atom.

Source

Examples


Last updated