Skip to main content

Security

What is Hashing?

Definition

Hashing maps input of any size to a fixed-size value with a one-way function, so the original cannot be recovered — which is why hashing is not encryption.

Also known as: Hash function, Digest

Hashing in more detail

The same input always produces the same hash, a different input almost always produces a different one, and there is no key and no way back. That combination makes hashes useful as fingerprints: verifying a download, detecting whether a file changed, addressing content by its digest as Git does, or spreading keys across buckets in a hash table.

Three families get confused. Non-cryptographic hashes such as xxHash and MurmurHash are for hash tables and checksums — fast, and trivially forgeable. Cryptographic hashes such as SHA-256 and BLAKE3 are collision-resistant and designed for integrity and signatures; they are also deliberately fast, which is exactly why they are wrong for passwords. Password hashes — Argon2id, bcrypt, scrypt — are deliberately slow and memory-hard, with a per-user salt so identical passwords produce different digests and precomputed rainbow tables are useless.

MD5 and SHA-1 are broken for security purposes: practical collisions exist for both, so neither should be used for signatures or integrity against an adversary, though they survive as non-security checksums in legacy tooling. And because hashing is one-way, a password database can only be checked, never decrypted — the correct verification is to hash the attempted password with the stored salt and compare the results in constant time.

Hashing example

SHA-256, deterministic and one-way
  "hello"  -> 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e...
  "hello!" -> ce06092fb948d9ffac7d1a376e404b26b7575bcc11ee05a4...
  A one-character change rewrites the whole digest.

Password storage — never SHA-256 alone
  $argon2id$v=19$m=65536,t=3,p=4$c29tZXNhbHQ$RdescudvJCsgt3ub+b+dWRWJTmaaJObG
                 └ memory  └ time  └ salt      └ digest

Verify:  argon2_verify(stored_hash, attempt) -> true / false
There is no decrypt step, because there is nothing to decrypt.

Hashing — common questions

Is hashing a type of encryption?
No. Encryption is reversible with a key; hashing is one-way and has no key to reverse it with. Describing a hashed password as 'encrypted' is a common error that leads to genuinely bad designs.
Why is SHA-256 the wrong choice for passwords?
Because it is fast by design. Modern hardware can compute billions of SHA-256 hashes per second, so a leaked table is brute-forced quickly. Argon2id, bcrypt and scrypt are deliberately slow and memory-hungry, which makes guessing expensive.
What is a salt?
A unique random value stored alongside each password hash and mixed into the hashing. It ensures two users with the same password get different digests and makes precomputed rainbow tables worthless. Salts are not secret — they just have to be unique.

Keep reading

Every definition in the set is indexed A-Z in the developer glossary, and the cheat sheets cover the syntax once you know what you are looking for.

Browse the A-Z glossary