32 bit HASH Code
Posted: Mon Apr 28, 2014 8:04 am
This is an interesting little routine. It will convert any string to a 32 bit hash suitable to be stored in a BH 4.
While it is not guaranteed to provide a unique value for every string, it does a pretty good job!
THIS IS NOT A SECURE HASH, and should not be used for security purposes.
The value is that it's simple and very fast to execute.
While it is not guaranteed to provide a unique value for every string, it does a pretty good job!
THIS IS NOT A SECURE HASH, and should not be used for security purposes.
The value is that it's simple and very fast to execute.
Code: Select all
02000 DEF Fnhash(&Hash_String$)
02010 LET Hash=0
02020 FOR _Hash=1 TO Len(Hash_String$)
02030 LET Hash+=Mod( (_Hash*Ord(Hash_String$(_Hash:_Hash))) , Inf )
02040 NEXT _Hash
02050 LET Fnhash=Hash
02060 FNEND