Computer Security

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.

SHA‑256strong general-purpose hash, no known collisions
1‑waya hash cannot be reversed to its input
+ saltunique value that defeats rainbow tables
Argon2idOWASP first choice for password hashing

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 difference between hashing and encryption - What Is Hashing?
Hashing
One-way, no key. Used to verify integrity and to store passwords. You can confirm a value matches a hash, but you can never read the original back. Best for: passwords, checksums, signatures.
Encryption
Two-way, uses a key. Used to protect confidentiality so the right key holder can read the data later. Best for: messages, files, and connections that must be read again.

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.

Why password hashes are made deliberately slow - What Is Hashing?
Fast hashes are wrong for passwords. SHA-256 is built to be fast, so an attacker with a leaked database can test billions of guesses per second against it. Password hashes use slow, memory-hard functions (Argon2id, bcrypt, scrypt) tuned so a single guess takes a fraction of a second, which makes mass guessing impractical while a real login stays instant.

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.

Hash GeneratorType any text to see its SHA hash, computed in your browser so nothing is sent anywhere
Salt and Pepper Hashing DemoHash a sample word to see why the same input gives the same hash without a salt, and how a unique salt defeats rainbow tables
bcrypt Cost Factor CalculatorPick a bcrypt cost factor to see the rough relative time to hash one password and how it trades attacker cost against login speed

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.

Nizam Ud Deen

Muhammad Nizam Ud Deen Usman is the founder of theCoreiTech and the author of The Local SEO Cosmos. Nizam works as an SEO consultant and content strategy expert with more than a decade of experience in digital marketing and IT, and he also founded ORM Digital Solutions, a digital agency serving medium and large businesses. He holds a degree from the University of Education, Lahore (Multan Campus), and was listed among the top 20 SEO experts in Pakistan in 2024. Nizam started theCoreiTech in 2012 to make computers easier to understand and use for everyone. Connect with Nizam on LinkedIn (seoobserver), X (@SEO_Observer), or at nizamuddeen.com.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button