Ready to switch over mug.

This commit is contained in:
C. Guy Yarvin 2014-09-02 13:13:12 -07:00
parent bc590ffa10
commit ad83c31753

View File

@ -1075,33 +1075,46 @@
:: section 2cD, insecure hashing :: :: section 2cD, insecure hashing ::
:: ::
++ fnv |=(a=@ (end 5 1 (mul 16.777.619 a))) :: FNV scrambler ++ fnv |=(a=@ (end 5 1 (mul 16.777.619 a))) :: FNV scrambler
++ mur ::
~/ %mur ++ mum :: mug with murmur3
|= [key=@ syd=@] ~/ %mum
?> (lte (met 5 syd) 1) |= a=*
=+ ^= row |^ (trim ?@(a a (mix $(a -.a) (mix 0x7fff.ffff $(a +.a)))))
|= [a=@ b=@] ++ spec :: standard murmur3
(con (end 5 1 (lsh 0 a b)) (rsh 0 (sub 32 a) b)) |= [syd=@ key=@]
=+ mow=|=([a=@ b=@] (end 5 1 (mul a b))) ?> (lte (met 5 syd) 1)
=+ len=(met 5 key) =+ ^= row
=- =. goc (mix goc len) |= [a=@ b=@]
=. goc (mix goc (rsh 4 1 goc)) (con (end 5 1 (lsh 0 a b)) (rsh 0 (sub 32 a) b))
=. goc (mow goc 0x85eb.ca6b) =+ mow=|=([a=@ b=@] (end 5 1 (mul a b)))
=. goc (mix goc (rsh 0 13 goc)) =+ len=(met 5 key)
=. goc (mow goc 0xc2b2.ae35) =- =. goc (mix goc len)
(mix goc (rsh 4 1 goc)) =. goc (mix goc (rsh 4 1 goc))
^= goc =. goc (mow goc 0x85eb.ca6b)
=+ [inx=0 goc=syd] =. goc (mix goc (rsh 0 13 goc))
|- ^- @ =. goc (mow goc 0xc2b2.ae35)
?: =(inx len) goc (mix goc (rsh 4 1 goc))
=+ kop=(cut 5 [inx 1] key) ^= goc
=. kop (mow kop 0xcc9e.2d51) =+ [inx=0 goc=syd]
=. kop (row 15 kop) |- ^- @
=. kop (mow kop 0x1b87.3593) ?: =(inx len) goc
=. goc (mix kop goc) =+ kop=(cut 5 [inx 1] key)
=. goc (row 13 goc) =. kop (mow kop 0xcc9e.2d51)
=. goc (end 5 1 (add 0xe654.6b64 (mul 5 goc))) =. kop (row 15 kop)
$(inx +(inx)) =. kop (mow kop 0x1b87.3593)
=. goc (mix kop goc)
=. goc (row 13 goc)
=. goc (end 5 1 (add 0xe654.6b64 (mul 5 goc)))
$(inx +(inx))
::
++ trim :: 31-bit nonzero
|= key=@
=+ syd=0xcafe.babe
|- ^- @
=+ haz=(spec syd key)
=+ ham=(mix (rsh 0 31 haz) (end 0 31 haz))
?.(=(0 ham) ham $(syd +(syd)))
--
:: ::
++ mug :: 31bit nonzero FNV1a ++ mug :: 31bit nonzero FNV1a
~/ %mug ~/ %mug