3 title/'2e: Insecure Hashing'
14Hashes an atom with the 32-bit FNV non-cryptographic hash algorithm. Multiplies
15`a` by the prime number 16,777,619 and then takes the [block](../2c.md) of size
165 off the product's end, producing an atom.
29 ++ fnv |=(a=@ (end 5 1 (mul 16.777.619 a)))
51Hashes `a` with the 31-bit nonzero FNV-1a non-cryptographic hash algorithm,
69 =+ b=[p=$(a -.a) q=$(a +.a)]
71 =+ c=(fnv (mix p.b (fnv q.b)))
72 =+ d=(mix (rsh 0 31 c) (end 0 31 c))
81 =+ f=(mix (rsh 0 31 c) (end 0 31 c))
84 $(c (fnv (mix c (cut 3 [d 1] a))), d +(d))
102 > (mug [1 2 3 4 5 ~])
112Implementation of the 32-bit
113[MurmurHash3](https://en.wikipedia.org/wiki/MurmurHash#Algorithm)
114non-cryptographic hash algorithm. Takes `a` as the seed, `b` as the key length
115in [blocks](../2c) of size 3, and `c` as the key, producing an atom.
135 |= [syd=@ len=@ key=@]
136 ?> &((lte (met 5 syd) 1) (lte (met 0 len) 31))
137 =/ pad (sub len (met 3 key))
138 =/ data (weld (rip 3 key) (reap pad 0))
139 =/ nblocks (div len 4) :: intentionally off-by-one
141 =+ [c1=0xcc9e.2d51 c2=0x1b87.3593]
142 =/ blocks (rip 5 key)
145 ?: =(0 i) hi :: negative array index
146 =/ k1 (snag (sub nblocks i) blocks)
147 =. k1 (sit (mul k1 c1))
149 =. k1 (sit (mul k1 c2))
152 =. hi (sum (sit (mul hi 5)) 0xe654.6b64)
154 =/ tail (slag (mul 4 nblocks) data)
158 ?+ tlen h1 :: fallthrough switch
159 $3 =. k1 (mix k1 (lsh 0 16 (snag 2 tail)))
160 =. k1 (mix k1 (lsh 0 8 (snag 1 tail)))
161 =. k1 (mix k1 (snag 0 tail))
162 =. k1 (sit (mul k1 c1))
164 =. k1 (sit (mul k1 c2))
166 $2 =. k1 (mix k1 (lsh 0 8 (snag 1 tail)))
167 =. k1 (mix k1 (snag 0 tail))
168 =. k1 (sit (mul k1 c1))
170 =. k1 (sit (mul k1 c2))
172 $1 =. k1 (mix k1 (snag 0 tail))
173 =. k1 (sit (mul k1 c1))
175 =. k1 (sit (mul k1 c2))
182 =. h (mix h (rsh 0 16 h))
183 =. h (sit (mul h 0x85eb.ca6b))
184 =. h (mix h (rsh 0 13 h))
185 =. h (sit (mul h 0xc2b2.ae35))
186 =. h (mix h (rsh 0 16 h))
215 > =e (cut 3 [0 2] eny) :: `eny` is 512 bits of entropy (a random number).
22731-bit MurmurHash3 scrambler
229Hashes `a` with the 31-bit MurmurHash3 non-cryptographic hash algorithm,
246 |^ (trim ?@(a a (mix $(a -.a) (mix 0x7fff.ffff $(a +.a)))))
251 =+ haz=(muk syd (met 3 key) key)
252 =+ ham=(mix (rsh 0 31 haz) (end 0 31 haz))
253 ?.(=(0 ham) ham $(syd +(syd)))
274 > (mum [1 2 3 4 5 ~])
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