String Hash Function
Dr. Ripon Patgiri
Dept of Computer Science & Engineering,
National Institute of Technology Silchar
Introduction
A hash function is any function that can be used to map data of
arbitrary size to fixed-size values, though there are some hash
functions that support variable length output.
The values returned by a hash function are called hash values,
hash codes, hash digests, digests, or simply hashes.
Hash functions are related to (and often confused with) checksums,
check digits, fingerprints, lossy compression, randomization
functions, error-correcting codes, and ciphers.
Although the concepts overlap to some extent, each one has its own
uses and requirements and is designed and optimized differently.
The hash function differs from these concepts mainly in terms of
data integrity.
String Hash Function
A hash function may be considered to perform three functions:
1. Convert variable-length keys into fixed length (usually machine word length or
less) values, by folding them by words or other units using a parity-preserving
operator like ADD or XOR.
2. Scramble the bits of the key so that the resulting values are uniformly
distributed over the keyspace.
3. Map the key values into ones less than or equal to the size of the table.
Properties
A good hash function satisfies two basic properties:
1. It should be very fast to compute
2. It should minimize duplication of output values (collisions)
Basic string hash function
Issues: Two different strings can be easily mapped into single a hash
value.
String Hash Function
Issues: Long strings creates very large number.
String Hash Function
Issues: Small length string has small sized hash value
Enhanced hashing
DJB
Issues: Small length string has small sized hash value
FNV
Issues: Small length string has small sized hash value
Murmur
https://github.com/
aappleby/smhasher
Thank you