32 bit HASH Code

More advanced topics discussed.

Moderators: Susan Smith, admin, Gabriel

GomezL
Posts: 232
Joined: Wed Apr 29, 2009 5:51 am
Contact:

32 bit HASH Code

Postby GomezL » 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.

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


Return to “Advanced Concepts”

Who is online

Users browsing this forum: No registered users and 1 guest

cron