Encryption protects confidentiality and can be reversed with the appropriate key. Cryptographic hashing produces a digest designed for one-way verification; it is not a method for recovering the original data.
Encryption
Use encryption when an authorized party must recover the original information. Examples include encrypted disks and protected network communication.
Encryption: key points
- Decryption requires the appropriate key and cryptographic process.
- Symmetric and asymmetric mechanisms have different key-management roles.
- Protect recovery material and access to decrypted data.
Hashing
Use a cryptographic hash to compare data or as a component of a verification mechanism. A digest has no decryption key. Password storage needs a dedicated password-hashing design with a salt and work factors.
Hashing: key points
- Preimage resistance makes deriving an input from its digest computationally impractical.
- Different inputs can in principle share a digest; collision resistance is a security property, not a uniqueness guarantee.
- A trusted reference digest matters when checking a downloaded file.
Comparison
| Criterion | Encryption | Cryptographic hashing |
|---|---|---|
| Main purpose | Confidentiality | Integrity checks and verification |
| Recover original data | With the appropriate key | No decryption operation |
| Key material | Required by the encryption scheme | An ordinary hash such as SHA-256 is unkeyed |
| Examples | Disk encryption and TLS encryption | SHA-256 for file digests; Argon2id or bcrypt for passwords |
Choose encryption when
You must keep information confidential while allowing authorized recovery of its original form.
Choose hashing when
You need an integrity check or an appropriate password-verification mechanism. HMAC adds a secret key to a message-authentication construction; an ordinary unkeyed hash alone does not authenticate a sender.
Key takeaways
Use password-hashing APIs for login passwords. Keep encryption keys recoverable according to your recovery plan. Encryption and hashing can be used together because they address different requirements.