elefcode
← All guides

Security · 5 min read

Hashing vs Encryption: What Is the Difference?

Hashing and encryption both scramble data, so they are easy to confuse — but they solve different problems and are not interchangeable. Choosing the wrong one is a common security mistake.

This guide explains what each does, when to use it, and why password storage relies on hashing rather than encryption.

Try it yourself with the related tool.

Generate a hash

Advertisement

Hashing is one-way

A hash function turns any input into a fixed-size fingerprint, and it is designed to be irreversible — you cannot get the original back from the hash. The same input always produces the same hash, and a tiny change to the input produces a completely different one. Hashing is for verifying integrity and comparing values, not for recovering data.

Encryption is two-way

Encryption transforms data so it can be read again later with the right key. It is for confidentiality — protecting data you need to recover, like a message or a file. AES is the standard symmetric cipher for this.

Why passwords are hashed

A service should never be able to read your password, so it stores a hash instead of the password itself. When you log in, it hashes what you typed and compares. Because hashing is one-way, a breach of the database does not directly expose the passwords — provided a slow, salted algorithm like bcrypt was used.

Why not a fast hash for passwords

General-purpose hashes like SHA-256 are fast, which helps attackers try billions of guesses per second. Password hashing uses deliberately slow, salted functions such as bcrypt or Argon2 to make large-scale guessing impractical.

Related guides