Hashing vs Encryption
Hashing is one-way: it turns input into a fixed-length digest that cannot be reversed, and is used to verify rather than to recover. Encryption is two-way: it transforms data so that a key holder can get the original back. Use hashing for passwords and integrity checks, and encryption when you genuinely need to read the data again later.
Hash Generator
Generate MD5, SHA-1, SHA-256 and SHA-512 digests at once.
These are often described as two ways of "scrambling" data, which is where the confusion starts. They are built for opposite purposes. Hashing deliberately destroys information so the original cannot be recovered. Encryption deliberately preserves it so the right person can.
The practical consequence is that choosing wrongly is not a matter of taste. Encrypting passwords instead of hashing them creates a database where every password is recoverable by anyone who obtains the key — and the key is usually on the same server.
The core difference
- Direction: hashing is one-way; encryption is reversible with the key.
- Key: hashing needs none; encryption is meaningless without key management.
- Output size: a hash is fixed-length regardless of input; ciphertext grows with the plaintext.
- Purpose: hashing answers "is this the same?"; encryption answers "keep this secret until I need it".
- Failure mode: a leaked hash of a strong password is near-useless; a leaked key exposes everything it protected.
When to hash
Whenever you need to check a value without storing it. Password storage is the obvious case: you never need the password back, only to confirm someone supplied the same one. Integrity checking is the other — a checksum proves a file arrived unaltered. Deduplication and cache keys are hashing too, though those need no cryptographic strength.
- Passwords — with a slow, salted function such as bcrypt or Argon2id, never a bare SHA-256.
- File and download integrity — SHA-256.
- Message authentication with a shared secret — HMAC.
- Content addressing, deduplication, cache keys.
When to encrypt
Whenever the original value has to be readable again. A stored payment token, a document at rest, a message in transit, an API credential your application must present to a third party — none of those work if the data is destroyed.
- Data in transit — TLS.
- Data at rest that must be read back — AES-GCM or another authenticated cipher.
- Secrets your application must present elsewhere, such as third-party API keys.
- Anything where "we need to show this to the user again" is a requirement.
The mistake that matters
Encrypting passwords. It sounds more secure because it sounds stronger, and it is strictly worse: it turns an irreversible store into a reversible one. Anyone who obtains the key — a backup, a config file, an attacker already inside the server — recovers every password in plaintext. Hashing has no key to leak. If a system can email you your existing password, it is not hashing them, and that is a reportable weakness rather than a convenience feature.
Where they work together
Real systems use both, for different jobs. TLS encrypts the connection and uses hashes inside its handshake and message authentication. A signed JWT is hashed via HMAC and sent over an encrypted channel. Encrypted data is often hashed afterwards to detect tampering — which is exactly what an authenticated cipher such as AES-GCM does for you.
Frequently asked questions
Is hashing more secure than encryption?
Why is encrypting passwords a bad idea?
Can a hash be decrypted?
Where does encoding fit in?
What about signing — is that hashing or encryption?
Tools used in this guide
All tools →- Hash Generator Generate MD5, SHA-1, SHA-256 and SHA-512 digests at once. In your browser
- SHA-256 Hash Generator Generate a SHA-256 digest — the modern default. In your browser
- Bcrypt Generator and Verifier Create and verify bcrypt password hashes. Server-side
- HMAC Generator Sign a message with a secret key using HMAC. In your browser
- Password Strength Checker Estimate how long a password would take to crack. In your browser
- Base64 Encoder and Decoder Encode text to Base64 or decode it back, including URL-safe. In your browser
Related guides
All guides →- Base64 vs Encryption Base64 is an encoding, not a cipher. What it is actually for, and why it protects nothing.
- Bcrypt vs Argon2 Which password hashing function to use now, and whether an existing bcrypt store needs replacing.
- How to Hash Text with SHA-256 Produce a SHA-256 digest, compare it against a published checksum, and know when SHA-256 is the wrong tool.
Last reviewed .