Return to xhash.fs CVS log | Up to [gforth] / gforth |
Added xorshift rng+hash
1: \ a more secure hash using xorshift RNG 2: 3: Variable seed 4: cell 4 = [IF] 5: : xorshift ( n -- n' ) 6: dup 1 lshift xor 7: dup 3 rshift xor 8: dup 10 lshift xor ; 9: [THEN] 10: cell 8 = [IF] 11: : xorshift ( n -- n' ) 12: dup 11 lshift xor 13: dup 23 rshift xor 14: dup 56 lshift xor ; 15: [THEN] 16: : rnd seed @ xorshift dup seed ! ; 17: 18: : xhash ( addr u -- hash ) 19: 0 -rot bounds ?DO 20: I c@ xor xorshift 21: LOOP ;