A hash function is a function used to verify the integrity of messages, by generating a fixed-length value (hash) from the input data. The hash can then be compared to the original hash to ensure that the data has not been tampered with.