A cryptographic hash is the fixed-length output produced by a cryptographic hash function, or, by extension, the cryptographic hash function itself when the context makes the meaning clear. A cryptographic hash function accepts an input of arbitrary practical length and deterministically produces a digest of a specified size. Its design aims to make several attacks computationally infeasible, particularly finding an input corresponding to a chosen digest, finding a second input with the same digest as a given input, and deliberately finding any two distinct inputs with the same digest. Common cryptographic hash functions include SHA-256 and SHA-3.
The principal security properties are commonly described as preimage resistance, second-preimage resistance and collision resistance. Preimage resistance means that given a digest, it should be computationally infeasible to find an input that hashes to it. Second-preimage resistance means that given one input, it should be infeasible to find a different input producing the same digest. Collision resistance means that it should be infeasible to find any two distinct inputs with the same digest. These properties are related but are not identical, and the precise security strength depends on the construction, output size and cryptanalytic state of the algorithm.
SHA-256 is a member of the SHA-2 family and produces a 256-bit digest. SHA-3 is based on the Keccak construction and uses a different internal design from SHA-2. Both are standardised cryptographic hash families used in many security applications. Older functions such as MD5 and SHA-1 are historically significant but have important collision-resistance weaknesses. The fact that an algorithm continues to produce deterministic outputs does not mean that it remains secure for every purpose; cryptographic algorithms must be evaluated against known attacks and appropriate security margins.
Cryptographic hashes are frequently used with digital signatures. Instead of signing an entire large document directly with a public-key signature algorithm, a system can calculate a cryptographic digest of the document and sign the digest using an appropriate signature scheme. The recipient recalculates the digest from the received document and verifies the signature. If the document has changed, the digest should differ and the signature verification will fail. The security of this construction depends on the cryptographic properties of the hash and the signature scheme, which is why weak or obsolete hash functions can compromise otherwise sound signature architectures.
Cryptographic hashes also support integrity mechanisms and content identification. A software publisher may provide a SHA-256 digest that users can compare with a locally calculated digest. Distributed systems can use cryptographic digests to identify objects or detect changes, while version-control and content-addressed systems can use hashes as identifiers or integrity references. A digest itself does not establish trust, however. If an attacker can replace both the software and the expected digest, the comparison may still succeed. Trust must therefore come from a protected distribution mechanism, authenticated signature, trusted channel or another mechanism that prevents unauthorised replacement of the reference value.
Password security requires special treatment because cryptographic hash functions are intentionally efficient. An attacker who steals a database of unsalted password hashes can potentially test enormous numbers of candidate passwords rapidly, particularly when users choose weak or reused passwords. Password-hashing functions such as Argon2 are deliberately designed to impose greater computational and memory costs and to support unique salts. A cryptographic hash such as SHA-256 can be an internal component of a password-based construction, but simply storing SHA-256(password) is generally inadequate password protection. The distinction between general cryptographic hashing and password-specific hashing is therefore operationally important.
Cryptographic hashing is also used in message authentication and key derivation, although usually through specialised constructions rather than by simply concatenating values and hashing them. HMAC, for example, combines a cryptographic hash function with a secret key in a standard construction that provides message authentication. Hash-based key-derivation functions can derive cryptographic keys from secret material while applying appropriate processing. These specialised constructions exist because naïve uses of a hash function may have security weaknesses related to message structure, length-extension properties or insufficient domain separation. Cryptographic protocols should therefore use standardised constructions rather than inventing combinations of hashes and secrets.
The practical strength of a cryptographic hash is influenced by digest size and the best known attacks against the underlying construction. For an ideal n-bit hash function, generic collision searching has an approximate square-root complexity of 2^(n/2), an effect known as the birthday bound, while generic preimage searching has complexity around 2^n. These figures explain why collision resistance and preimage resistance have different nominal strengths for the same digest length. Real algorithms may have additional weaknesses or attacks, so theoretical generic bounds are not substitutes for current cryptographic analysis. A cryptographic hash should therefore be selected according to its standard status, security properties, output size, application requirements and current expert guidance.