2title = "2e: Insecure Hashing"
11Hashes `a` with the 31-bit murmur3 non-cryptographic hash algorithm,
28 |^ ?@ a (mum 0xcafe.babe 0x7fff a)
29 =/ b (cat 5 $(a -.a) $(a +.a))
30 (mum 0xdead.beef 0xfffe b)
33 |= [syd=@uxF fal=@F key=@]
38 =/ haz=@F (muk syd wyd key)
39 =/ ham=@F (mix (rsh [0 31] haz) (end [0 31] haz))
40 ?.(=(0 ham) ham $(i +(i), syd +(syd)))
77Implementation of the 32-bit
78[MurmurHash3](https://en.wikipedia.org/wiki/MurmurHash#Algorithm)
79non-cryptographic hash algorithm. Takes `syd` as the seed, `len` as the key length
80in [blocks](/docs/hoon/reference/stdlib/2c) of size 3, and `key` as the key, producing an atom.
97++ muk :: standard murmur3
100 |= [syd=@ len=@ key=@]
102 =/ pad (sub len (met 3 key))
103 =/ data (weld (rip 3 key) (reap pad 0))
104 =/ nblocks (div len 4) :: intentionally off-by-one
106 =+ [c1=0xcc9e.2d51 c2=0x1b87.3593]
107 =/ blocks (rip 5 key)
111 =/ k1 (snag (sub nblocks i) blocks) :: negative array index
112 =. k1 (sit (mul k1 c1))
114 =. k1 (sit (mul k1 c2))
117 =. hi (sum (sit (mul hi 5)) 0xe654.6b64)
119 =/ tail (slag (mul 4 nblocks) data)
123 ?+ tlen h1 :: fallthrough switch
124 %3 =. k1 (mix k1 (lsh [0 16] (snag 2 tail)))
125 =. k1 (mix k1 (lsh [0 8] (snag 1 tail)))
126 =. k1 (mix k1 (snag 0 tail))
127 =. k1 (sit (mul k1 c1))
129 =. k1 (sit (mul k1 c2))
131 %2 =. k1 (mix k1 (lsh [0 8] (snag 1 tail)))
132 =. k1 (mix k1 (snag 0 tail))
133 =. k1 (sit (mul k1 c1))
135 =. k1 (sit (mul k1 c2))
137 %1 =. k1 (mix k1 (snag 0 tail))
138 =. k1 (sit (mul k1 c1))
140 =. k1 (sit (mul k1 c2))
147 =. h (mix h (rsh [0 16] h))
148 =. h (sit (mul h 0x85eb.ca6b))
149 =. h (mix h (rsh [0 13] h))
150 =. h (sit (mul h 0xc2b2.ae35))
151 =. h (mix h (rsh [0 16] h))
180 > =e (cut 3 [0 2] eny) :: `eny` is 512 bits of entropy (a random number).
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list