A hash is a short fixed-length value calculated from a file's contents. Any change to the file, even a single character, changes the result, so a hash can confirm that a file is unaltered. It is produced by a hash function, and the same input always gives the same output.

It matters in software security because it gives a way to check that what you received is what was published. Lockfiles and SBOMs often record the hash of each package, so a tool can detect whether a package has been replaced or modified since it was recorded.

A hash shows that a file matches a recorded value, but not that the value itself can be trusted. If an attacker can change both the file and the recorded hash, the check passes, so the hash has to come from a trusted source. Older hash functions have known weaknesses, so the choice of function matters. A hash is not encryption, and the original file cannot be recovered from it.

To use hashes well, take them from a trusted channel, use a current hash function and let your tools check them automatically.