Hash is a function that takes any size input and returns a fixed-length string. The hash function is built in such a way that finding an input that will yield a specific output is extremely difficult (i.e. the hash value). This is what makes it a valuable tool for ensuring data integrity. The hash of a file is calculated and saved in a public database when a user downloads it. The hash is calculated again when the file is uploaded and compared to the value stored in the database. It's presumed that the file hasn't been changed if the two values match. The hash function is one of the most fundamental cryptographic methods. A hash function takes any size input and returns a set size result. A hash code or hash value is the result of a hash function. In cryptography, hash functions are used to construct a message digest. A message digest is a compressed version of the original message. A message's hash code is calculated and then saved with the message. The hash code is computed anew when the message is received and compared to the previously stored hash code. If the hash codes are the same, the message hasn't changed since it was last encrypted.