Annotation of gforth/xhash.fs, revision 1.1
1.1 ! pazsan 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 ;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>