A hash function is a function that maps a large number of arbitrary data types onto a smaller number of contiguous integers.
The base set here is a number of strings of arbitrary length, which is a theoretically open ended set size. The target is a bounded number of integer values. It is thus inevitable that two strings exist which are mapped to the same target number, a hash value collision.
Hash functions are useful in computer science, and you have been using them in everyday life, or at least seen them:
- as checksums
- to quickly assign a position to an arbitrary object
- or to create object identity from content.