Download a file from a software website and you may see a long string labelled "SHA-256 checksum". Developers talk about hashing passwords, and blockchains are built on hashes. So what is a hash function, why is it so useful, and why do security experts say MD5 should no longer be trusted? Here is a straightforward explanation.
A digital fingerprint
A hash function takes any input – a word, a password or a 4 GB video – and produces a fixed-length string called a hash or digest. Think of it as a fingerprint for data.
For example, the SHA-256 hash of the word "hello" is:
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
And the MD5 hash of "hello" is:
5d41402abc4b2a76b9719d911017c592
The key properties
A good cryptographic hash function is:
- Deterministic – the same input always gives the same hash.
- Fixed length – SHA-256 is always 64 hex characters, whatever the input size.
- One-way – you cannot work backwards from the hash to the input.
- Avalanche effect – change one letter ("hello" → "Hello") and the hash changes completely.
- Collision-resistant – it should be practically impossible to find two different inputs with the same hash.
Common algorithms
- MD5 – 128-bit (32 hex characters). Fast but broken: researchers can create collisions, so it must not be used for security. Still fine for non-security checks like spotting accidental file corruption.
- SHA-1 – 160-bit (40 characters). Also considered broken for security since practical collisions were demonstrated in 2017.
- SHA-256 – 256-bit (64 characters), part of the SHA-2 family. The current standard for checksums, certificates and blockchains.
- SHA-3 – a newer family designed as an alternative to SHA-2.
Where hashes are used
- Verifying downloads: compare the published checksum with the hash of the file you downloaded. If they match, the file is intact and unaltered.
- Detecting duplicate files without comparing them byte by byte.
- Digital signatures and SSL certificates.
- Version control: Git identifies every commit by a hash.
- Blockchains: each block includes the hash of the previous one.
Hashing passwords: do it properly
Storing passwords as plain MD5 or SHA-256 hashes is not safe. These algorithms are designed to be fast, so attackers can test billions of guesses per second, and precomputed tables crack common passwords instantly.
Proper password hashing uses slow, salted algorithms built for the job:
- bcrypt
- Argon2 (the modern recommendation)
- scrypt or PBKDF2
A salt – a random value added to each password before hashing – ensures two users with the same password get different hashes. Frameworks such as Laravel, Django and ASP.NET do this for you; use their built-in functions rather than rolling your own. On the user side, strong unique passwords still matter – see how to create a strong password.
Hashing vs encoding vs encryption
- Encoding (like Base64) is reversible by anyone – see what is Base64 encoding.
- Encryption is reversible with the right key.
- Hashing is one-way and cannot be reversed.
Generate hashes instantly
The free Hash Generator creates MD5, SHA-1, SHA-256 and other hashes of any text in your browser, so nothing is uploaded. It is handy for comparing checksums, learning how hashing works and testing code. You may also find the UUID Generator and Password Generator useful.
Frequently asked questions
Can a hash be decrypted? No. Hashes are one-way. "Hash crackers" simply guess inputs and compare results.
Why do two different files sometimes share an MD5 hash? Because MD5 collisions can be deliberately created. Use SHA-256 for integrity checks that matter.
Is SHA-256 safe for passwords? On its own, no – it is too fast. Use bcrypt or Argon2.
Summary
So, what is a hash function? A one-way process that turns any data into a fixed-length fingerprint. Use SHA-256 for checksums and integrity, avoid MD5 and SHA-1 for security, and store passwords only with salted, slow algorithms like bcrypt or Argon2. Try it yourself with the free Hash Generator.