The difference in one sentence each
A hash turns any input into a fixed-size fingerprint that cannot be turned back. Encryption scrambles data so that only someone with the key can turn it back. Encoding, such as Base64, only changes how bytes are written and needs no key at all. Mixing them up is behind many security bugs: Base64 used to "hide" passwords, SHA-256 used to "encrypt" them, or encryption used where a hash was needed.
Side by side
| Hash | Encryption | Encoding | |
|---|---|---|---|
| Reversible | no | yes, with the key | yes, by anyone |
| Needs a key | no (HMAC adds one) | yes | no |
| Output size | fixed (SHA-256: 32 bytes) | about the input size | larger (Base64: +33%) |
| Purpose | integrity, lookups, passwords | confidentiality | transport as text |
| Examples | SHA-256, SHA-3, BLAKE3, bcrypt | AES-GCM, ChaCha20, RSA, ECIES | Base64, hex, URL encoding |
Hashes
The same input always gives the same digest, and the smallest change gives a completely different one: the SHA-256 of hello is 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824. That makes hashes ideal to check that a download was not altered, to deduplicate files and to compare values without storing them. Try any algorithm in the hash generator. Two warnings: old hashes like MD5 and SHA-1 have known collisions (MD5 vs SHA-256), and a fast hash alone is the wrong tool for passwords.
A keyed hash (HMAC) mixes a secret into the hash, so only someone with the key can produce or check it. Webhooks and API signatures use it; see the HMAC generator.
Encryption
- Symmetric encryption (AES, ChaCha20) uses the same key to encrypt and decrypt. It is fast and protects files, disks and the data inside HTTPS connections. Use an authenticated mode such as AES-GCM, which also detects tampering. The text encryption tool shows the idea.
- Asymmetric encryption (RSA, elliptic curves) uses a public key to encrypt and a private key to decrypt, which solves how two parties agree on a key. In practice it protects a symmetric key, which then protects the data.
Passwords: a special case
Passwords must not be encrypted (whoever has the key reads them all) and must not be stored with a fast hash (attackers test billions of guesses per second on a GPU). They need a slow, salted password hash: Argon2id, bcrypt, scrypt or PBKDF2. Details and recommended settings are in how to store passwords; you can try one in the bcrypt generator.
FAQ
Can a hash be decrypted?
No, there is no key and no way back. "Hash crackers" only guess inputs and compare digests, which works for short or common texts.
Is Base64 a kind of encryption?
No, it is an encoding: reversible by anyone, with no key. See what is Base64.
Should I hash or encrypt credit card numbers?
If you only need to recognize a card again, keep a keyed hash or a token from your payment provider; if you must read the number back, encrypt it and protect the key. Most shops should store neither and let the payment provider keep it.
Is SHA-256 encryption?
No. SHA-256 is a hash function: it has no key and cannot be reversed.