Hash function
A hash function maps input data of any practical length to a fixed-size digest.
Definition
A hash function takes data and calculates a fixed-size value called a hash, digest, or fingerprint. The same input bytes always produce the same output, while even a small input change should usually change the digest.
Hashing is not encryption. A digest is not meant to be decoded or decrypted back into the original message; it is used for comparison, identification, integrity checks, and as a component inside larger cryptographic constructions.
Cryptographic properties
A cryptographic hash function is designed to resist preimage attacks, second-preimage attacks, and collisions. In simple terms, it should be hard to find an input for a given digest, hard to find a different input with the same digest as a chosen message, and hard to find any two inputs with the same digest.
Algorithms such as SHA-256, SHA-512, SHA-3, and BLAKE2 are used in modern systems. MD5 and SHA-1 are still seen in legacy checksums, but their collision resistance is broken and they should not protect security-sensitive data.
Uses and common confusion
Hashes are commonly displayed as hexadecimal strings. For example, SHA-256 produces 32 bytes, usually written as 64 hex characters. Comparing a newly calculated digest with a trusted published digest can show whether data changed.
A plain hash does not authenticate who created the data. Use an HMAC or a digital signature when an attacker may deliberately modify content, and use a password-hashing function such as Argon2id or bcrypt instead of a fast raw hash for password storage.
No. A hash is a one-way digest, not ciphertext. Someone can only guess possible inputs, hash them, and compare the results.
They overlap in use, but not in security. A checksum detects accidental changes, while a cryptographic hash is designed to resist certain deliberate attacks.
They may use different algorithms or hash different bytes. Spaces, line endings, Unicode normalization, text encodings, and file-versus-text input all affect the result.