A hash function is a mathematical operation that transforms an input of arbitrary size into a fixed-size value, known as a hash or message digest. This "fingerprint" is crucial for quickly locating data within a hash table or verifying data integrity.