Back to glossary

Hash function

2 min read

In cryptography, a hash function turns arbitrary input into a fixed-size fingerprint that is hard to reverse. A cryptographic hash must resist preimage, second-preimage and collision attacks; it underpins integrity checks and digital signatures. Passwords are the exception: they need a purpose-built key derivation function, never a fast general-purpose hash.

July 24, 2026
Compartir:

How it works

A hash function maps any input to a fixed-length output, deterministically, so the same input always yields the same digest and any change to the input changes it. A cryptographic hash such as SHA-2, SHA-3 or BLAKE2 must hold three properties: preimage resistance (given a digest, you cannot find an input that produces it), second-preimage resistance (given an input, you cannot find a different input with the same digest), and collision resistance (you cannot find any two inputs that collide). These properties are what let a hash verify that a file was not altered and let a digital signature sign a document by signing its digest. Speed is a feature here: verifying integrity should be fast.

What goes wrong

Speed is exactly why a general-purpose hash is the wrong tool for storing passwords, and calling a hash “foundational to passwords” is itself the finding we raise. A fast hash lets an attacker try billions of guesses per second against a stolen database, so passwords need a key derivation function such as Argon2id, which is deliberately slow and memory-hard. The other real-world failure is treating “one-way” as sufficient: MD5 and SHA-1 remain one-way, but their collision resistance is broken, and collision is precisely the property a signature relies on, so a broken hash under a signature is a genuine forgery risk even though nobody can reverse it. The property that matters depends on the use.

Where this shows up in an audit

Wherever hashing appears we check that the algorithm fits the purpose. For password storage we flag any general-purpose hash, even with a salt, because the salt removes precomputation but not speed. For signatures and integrity we flag MD5 and SHA-1 for their broken collision resistance. For keyed integrity we check that an HMAC construction is used rather than a naive hash of a key and message. The finding is written against the mismatch between the algorithm and what it is protecting, because a hash used for the wrong job is a defect regardless of the algorithm’s strength.

¿Quieres ver cómo trabajamos en Asperis Security?

Agenda 30 minutos con uno de nuestros especialistas. Revisamos tu stack y te decimos qué conviene probar primero.