Download a file and you will often see a long string of hex characters beside it. That string is a hash — a fingerprint of the file's exact contents. Change one byte and the fingerprint changes completely. That single property quietly protects your downloads, your passwords, and much of the internet.

What a hash function does

A hash function takes input of any size — a password, a document, an entire movie — and produces a fixed-size output called a digest. SHA-256, the most widely used hash function today, always produces 256 bits, written as 64 hexadecimal characters, no matter whether the input is one letter or one gigabyte. The same input always produces the same digest, and the process runs in one direction only: there is no "unhash" button.

Three properties make a hash function useful. First, it is deterministic: hashing the same file twice gives the same result, so the digest works as an identity check. Second, it is avalanche-like: changing a single character in the input scrambles roughly half the output bits, so similar inputs produce wildly different digests. Third, it is practically irreversible: recovering the input from the digest would require trying candidates until one matches, and at 256 bits that search is larger than the number of atoms in the observable universe.

That last point deserves a caveat. "Irreversible" means no shortcut exists, not that guessing is impossible. If the input is a short, common password like password123, an attacker can simply hash a list of common passwords and look for a match. Hashing protects data; it does not magically make a weak secret strong. That distinction is exactly why password hashing needs extra steps, covered below.

Checksums: proving a file is the file

The most everyday use of hashing is the checksum. When you download software, the publisher publishes the file's SHA-256 digest alongside it. After downloading, you hash your copy and compare. If the two strings match character for character, your file is bit-for-bit identical to the publisher's — no corruption in transit, no tampering, no substitution. If even one character differs, something changed, and you should not trust the file.

The same idea powers version control, backups, and content-addressed storage. Git identifies every commit and file by its hash, so a repository can detect corruption or tampering automatically. Backup tools hash files to find duplicates and verify restores. Package managers hash downloads before installing them. In each case the hash answers one question cheaply and reliably: is this exactly the data I expect?

Try it yourself sometime: hash a text file, change one letter, and hash it again. The two digests will look nothing alike. That avalanche effect is what makes a 64-character string a trustworthy stand-in for a file of any size.

Why password hashing is not encryption

Encryption is reversible by design: encrypt a message with a key, decrypt it with the key, and the original returns. Password storage must never work that way, because a stolen database of encrypted passwords could be decrypted if the key leaks. Instead, systems store only the hash. When you log in, the system hashes what you typed and compares digests. It never needs to know your actual password, and neither does an attacker who steals the database.

But plain hashing is not enough for passwords, for the reason above: common passwords can be guessed by hashing candidates. Modern password storage therefore adds two defenses. Salting appends a unique random value to each password before hashing, so identical passwords produce different digests and precomputed rainbow tables become useless. Slow hashing algorithms like bcrypt, scrypt, and Argon2 are deliberately expensive to compute, turning a billion-guesses-per-second attack into a few dozen — enough to make even a leaked database painful to crack.

The practical lesson for users is simple: a site that stores passwords properly can survive a breach with your password still secret, provided your password is not on a common-password list. A unique, reasonably long password plus a well-implemented hash is why breaches of well-run services rarely lead to mass account takeovers, while breaches of poorly run ones do.

Hashes beyond passwords: blockchains and signatures

Hashes also hold together two technologies you have heard of even if you never touch them. In a blockchain, each block contains the hash of the previous block, forming a chain: altering any old transaction changes its block's hash, which breaks every link after it, making tampering visible to the whole network. In digital signatures, a document is hashed and the hash is encrypted with a private key; anyone can verify the signature by hashing the document themselves and checking the result. The signature proves both who signed and that the document has not changed since.

Not every hash function is still trustworthy. MD5 and SHA-1 were once standard, but researchers have demonstrated collisions — two different inputs producing the same digest — for both. A collision breaks the "unique fingerprint" promise, so MD5 and SHA-1 should no longer be used for security purposes. SHA-256 and its SHA-2 and SHA-3 siblings remain the safe defaults, and any tool or tutorial still recommending MD5 for integrity checks is out of date.

Hash functions are one of those quiet ideas that make the modern internet work: a short, fixed fingerprint that proves data is intact, stores passwords without knowing them, and chains records into tamper-evident history. The next time you see a checksum beside a download, it is worth the ten seconds to compare it — that string is doing more work than it looks.

AdvertisementAd slot: in-content

Frequently asked questions

Is hashing the same as encryption?

No. Encryption is reversible with a key: it scrambles data so it can be restored later. Hashing is one-way: it produces a fixed fingerprint that cannot be turned back into the original data. That is why passwords are hashed rather than encrypted, so even a stolen database does not reveal them.

Why did my downloaded file's checksum not match?

A mismatch means your copy differs from the publisher's file by at least one byte. The cause is usually a corrupted or incomplete download, but it can also mean the file was tampered with. Delete it, download again from the official source, and check the hash a second time before running it.

Why are MD5 and SHA-1 no longer recommended?

Researchers have demonstrated collisions for both: different inputs that produce the same digest. A collision breaks the core promise that a hash uniquely identifies its data. SHA-256 and the SHA-2 and SHA-3 families have no known practical collisions and are the safe defaults.

If hashing is one-way, how do attackers crack hashed passwords?

They guess. An attacker hashes candidate passwords from wordlists and breach databases and looks for a match with a stolen digest. Salting makes each guess unique per user, and slow algorithms like bcrypt and Argon2 make each guess expensive, which is why unique, longer passwords survive breaches.