Skip to content
TopicTracker
From HackerNewsView original
TranslationTranslation

Hash Functions

The page describes and provides C source code for two simple hash functions for strings: the djb2 hash (a variant of Dan Bernstein's algorithm starting with hash 5381) and the sdbm hash (used in the sdbm database library). Both functions are presented as effective, general-purpose hashing algorithms for string keys.

Background

- A hash function is a mathematical algorithm that takes an input (like a string of text) and produces a fixed-size output (called a hash, digest, or checksum), typically a number. Even a tiny change to the input produces a completely different hash.

Related stories