What Is Hashing?
Hashing is a one-way function that turns any input, of any size, into a fixed-length string called a hash or digest, which cannot be reversed back to the original. The same input always produces the same hash, but even a one-character change produces a completely different one. That makes hashing ideal for two jobs: storing passwords safely (you keep the hash, never the password) and verifying that a file or message has not been altered. It is not encryption, because there is no key and no way to get the original data back.
What Is Hashing?
A hash function maps data to a fixed-length digest with a set of defining properties. A function counts as a secure hash only if it is:
- Deterministic: the same input always yields the same hash.
- Fixed-length: a one-word input and a whole book both produce a digest of the same size (256 bits for SHA-256).
- One-way: it is infeasible to work backward from a hash to the input.
- Avalanche effect: a tiny change to the input flips roughly half the output bits.
- Collision-resistant: it is infeasible to find two different inputs that hash to the same value.
Hashing vs Encryption
The core difference is reversibility: encryption can be undone with a key, hashing cannot be undone at all.

The reversible side is covered in how encryption works. A common mistake is to say a leaked database was “encrypted” when the passwords were actually hashed; the two give very different guarantees.
How Are Passwords Stored With a Hash?
Good systems never store your password. They store a salted hash of it and compare hashes at login.
- Generate a salt. The system creates a unique random value for your account.
- Hash with a slow function. It combines your password with the salt and runs a deliberately slow algorithm (bcrypt, scrypt, or Argon2).
- Store the digest and salt. Only the resulting hash and the salt are saved, never the password.
- Verify at login. Your next attempt is hashed with the same salt and compared to the stored hash. A match logs you in.
Because each account has its own salt, two people with the same password get different hashes, and an attacker cannot use a precomputed rainbow table. A salt is not secret; its job is uniqueness, not concealment.
Why Are Password Hashes Made Deliberately Slow?
Speed is a virtue for file integrity but a weakness for passwords.

Which Hash Algorithms Are Safe in 2026?
Use SHA-256 for integrity and a slow function for passwords; avoid MD5 and SHA-1 entirely.
- MD5: broken since 2004 (practical collisions). Never use it for security.
- SHA-1: broken in 2017 by the SHAttered collision. Retired from signatures and integrity.
- SHA-256 (SHA-2): the safe default for checksums, signatures, and general integrity.
- SHA-3: a newer standard with a different internal design, available as an alternative to SHA-2.
- Argon2id, bcrypt, scrypt: the slow, salted functions made specifically for passwords. Argon2id is OWASP’s first choice.
This is also why a strong, unique password matters: it is the input a slow hash protects. The economics of guessing are covered in what a brute-force attack is.
Last Thoughts on Hashing
Hashing turns any input into a fixed-length, one-way digest, which makes it the right tool for storing passwords and verifying integrity rather than for keeping data readable. It is not encryption: there is no key and no way back. Passwords should be salted and run through a deliberately slow function such as Argon2id or bcrypt, while SHA-256 covers general integrity and the broken MD5 and SHA-1 should be left behind.
Hashing underpins password storage, digital signatures, and file verification across security. The hub on cybersecurity connects it to the wider set of defenses.
Key Takeaways:
- Hashing is a one-way function from any input to a fixed-length digest.
- It cannot be reversed, which is the difference from encryption.
- Passwords are stored as salted hashes and compared at login, never kept in plaintext.
- A unique salt per account defeats rainbow tables; the salt is not secret.
- Password hashes use slow functions (Argon2id, bcrypt, scrypt) to stop mass guessing.
- Use SHA-256 for integrity; never use MD5 or SHA-1 for security.
Frequently Asked Questions (FAQs)
What is the difference between hashing and encryption?
Hashing is a one-way function that cannot be reversed and verifies integrity. Encryption is reversible with a key and protects confidentiality. Hashed data cannot be returned to its original form.
Can a hash be reversed?
No. A secure hash function is one-way, so recovering the input from the hash is computationally infeasible. Attackers instead guess inputs and compare hashes, which salting and slow algorithms resist.
Why are passwords hashed instead of encrypted?
Passwords are hashed so a database leak does not expose plaintext credentials. The system never needs the original password back; it only compares the hash of a login attempt to the stored hash.
What is a salt in hashing?
A salt is a unique random value added to each password before hashing. It ensures identical passwords produce different hashes and defeats precomputed rainbow table attacks.
Is SHA-256 secure?
Yes. SHA-256, part of the SHA-2 family standardized by the National Institute of Standards and Technology, has no known practical collisions and is widely used for integrity and signatures.
Why are MD5 and SHA-1 no longer used?
MD5 and SHA-1 are deprecated because researchers demonstrated practical collisions, where two different inputs produce the same hash. This breaks their use in signatures and integrity verification.


