
Hashing vs encryption: the core difference
Hashing and encryption both protect data with math, but they solve different problems. Encryption is reversible: it turns readable data into ciphertext that the correct key converts back to the original. Hashing is one-way: it produces a fixed-length digest that cannot be reversed to reveal the input. Use encryption when you need the data back later, such as a stored tax return. Use hashing when you only need to confirm data matches a known value, such as verifying a password without storing it.
Getting this wrong is one of the most common and costly mistakes in applied security. The 2012 LinkedIn breach exposed roughly 6.5 million password hashes stored as unsalted SHA-1, a fast algorithm never meant for passwords, and attackers cracked them within hours. The 2022 LastPass incident showed the other side: attackers copied encrypted vault data, but the plaintext stayed out of reach without each user's decryption key. According to the IBM Cost of a Data Breach Report 2024, the global average breach cost reached $4.88 million, so the price of choosing the wrong method is not theoretical.
NIST cryptographic standards treat these as complementary tools: encryption for data that must be retrieved (financial records, communications, tax documents) and hashing for verification and authentication (password storage, file integrity, digital signatures). They are not interchangeable.
Quick Answer
Encryption is reversible and hashing is not. Encryption converts data into ciphertext that the right key decrypts back to the original, so use it when the data must be read again. Hashing produces a fixed-length, one-way digest with no key and no way back, so use it to verify integrity or confirm a password without storing it. Encrypting passwords instead of hashing them is a security failure even when the algorithm is strong, because the decryption key becomes a single point of theft.
What encryption is and how it works
Encryption transforms readable plaintext into unreadable ciphertext using an algorithm and a cryptographic key, and the same key material reverses the process. That reversibility is the whole point: it protects data you still need to open later.
Two modes cover most uses. Symmetric encryption uses one shared key for both directions; AES-256, recommended by NIST, is the standard for data at rest and is considered infeasible to brute-force with current computing. Asymmetric encryption uses a linked public and private key pair; RSA and Elliptic Curve Cryptography (ECC) secure key exchange and digital signatures, and because they are slower, they usually protect a symmetric session key rather than bulk data.
Reach for encryption when data must be retrieved: customer records, financial transactions, patient information, backups, and traffic in transit. HIPAA, PCI DSS 4.0, and the FTC Safeguards Rule all require encryption for specific data categories, with documented justification when it is not used.
What hashing is and how it differs
Hashing converts input of any size into a fixed-length string, called a digest, using a one-way function. A cryptographic hash cannot be reversed to reveal the original input, which is exactly why it suits verification and authentication rather than protecting data you need to read back.
Four properties define a cryptographic hash function:
- Deterministic: the same input always yields the same digest.
- Avalanche effect: changing a single character produces a completely different digest, so tampering is easy to spot.
- Collision resistance: it should be infeasible for two different inputs to produce the same digest.
- One-way: recovering the input from the digest is impractical by design, because there is no decryption step.
MD5 and SHA-1 were once standard and are now considered cryptographically broken because of demonstrated collision attacks. The OWASP Password Storage Cheat Sheet and NIST guidance point to SHA-256, SHA-3, or purpose-built password hashing algorithms for security-relevant work.
Password hashing and salting
Password storage is the most important and most mishandled use of hashing. Never store passwords in plaintext or with reversible encryption; both have caused breaches exposing millions of credentials. General-purpose hashes like SHA-256 are built for speed, and modern GPUs compute billions of them per second, so they are the wrong choice for passwords.
Use a slow, purpose-built password hashing algorithm instead. bcrypt has been dependable since 1999 and offers a tunable work factor. Argon2 won the 2015 Password Hashing Competition and resists GPU and ASIC attacks, and NIST points to Argon2id for new systems. scrypt is memory-hard and used in high-security settings. A salt is a unique random value added to each password before hashing; without it, identical passwords produce identical digests that attackers crack in bulk with precomputed rainbow tables. With a unique salt per user, each password has to be attacked on its own.
Password Security Implementation Checklist
- Use bcrypt, Argon2id, or scrypt for password hashing, never SHA-256 or MD5
- Generate a cryptographically random, unique salt for each password
- Store salts alongside the hashed passwords in your database
- Set a configurable work factor so you can raise cost as hardware improves
- Never store passwords in plaintext or with reversible encryption
- Force password resets if you find a deprecated hashing algorithm in use
- Document your password hashing method and work factor in your security policy or WISP
- Test your implementation against the OWASP Password Storage Cheat Sheet
Deprecated algorithms still in use
MD5 and SHA-1 are cryptographically broken and must not be used for password storage or security-relevant hashing. If your application uses either for passwords, treat it as an active vulnerability: migrate to Argon2id or bcrypt and force resets for affected accounts. The 2012 LinkedIn breach that exposed roughly 6.5 million credentials used unsalted SHA-1, an algorithm researchers had flagged years earlier.
File integrity verification in practice
Hashing is also the standard way to detect unauthorized file changes. Software vendors publish a SHA-256 hash next to a download so you can confirm the file was not altered in transit; running the hash locally and comparing values takes seconds. Security teams use File Integrity Monitoring (FIM), which continuously hashes system files and alerts when a digest changes unexpectedly. The MITRE ATT&CK framework references this as a detection control for persistence and defense-evasion tactics. Building the same hash check into backups confirms restored data matches its pre-backup state, ruling out corruption or tampering during storage.
File Integrity Verification Process
Generate a baseline hash
Run SHA-256 on critical files and system binaries before deployment, and store the hashes in a secure, write-protected location separate from the files themselves.
Schedule periodic verification
Automate hash comparisons on a regular schedule using FIM tools or scripted checks, and alert immediately on any mismatch.
Validate downloads and transfers
Before running downloaded software or restoring a backup, compare the file's SHA-256 hash against the vendor-published or pre-transfer value.
Document and investigate mismatches
Treat any hash mismatch as a potential security event, follow your incident response plan to determine whether the change was authorized, and log all findings.
Where hashing and encryption work together
Most mature systems use both. When your browser opens an HTTPS connection, asymmetric encryption (RSA or ECC) exchanges a session key, symmetric AES-256 protects the traffic, and HMAC-SHA256 confirms messages were not tampered with. Certificate checks use hashing to validate the server's signature. Digital signatures combine the two directly: you hash a document, encrypt that hash with your private key, and a recipient decrypts it with your public key and re-hashes the document. Matching results prove the document is unaltered and came from you, and hashing it first keeps the process fast while providing non-repudiation.
One warning: encoding is not security. Base64 turns binary data into text for transmission and is instantly reversible with no key. CISA guidance treats mistaking encoding for encryption as a source of false confidence that leaves data exposed. Put that point in security awareness training so staff understand that encoded URLs, attachments, or data files offer no real protection against a determined attacker.
Bottom line
Hashing and encryption are not interchangeable. Encrypt data you must retrieve; hash data you only need to verify or authenticate. Applying the wrong method, like encrypting passwords instead of hashing them, creates real, exploitable weakness no matter how strong the underlying algorithm.
Choosing the right method
Ask one question: does this data need to be retrieved in its original form? If yes, encrypt it. If you only need to confirm that a value matches a known one, hash it.
Use hashing to store passwords (salted, with bcrypt, Argon2id, or scrypt), verify file integrity, fingerprint documents, and build authentication or digital signatures that never recover the original value. Use encryption to protect data you retrieve later (customer records, financial and tax data), secure transmission over HTTPS and VPNs, protect backups and cloud storage, and meet confidentiality rules under HIPAA, PCI DSS 4.0, and GDPR. Across every framework the technical baseline is consistent: AES-256 or equivalent for encryption, bcrypt or Argon2id for passwords, no MD5, SHA-1, or DES, and documented cryptographic controls. If you want the model behind these choices, our guide to the CIA triad shows how confidentiality and integrity map to each method.
Compliance requirements across regulated industries
Tax professionals under IRS Publication 4557 and the FTC Safeguards Rule must encrypt taxpayer data at rest and in transit and document those controls in a Written Information Security Plan (WISP), which the IRS expects firms to maintain and update annually. Password hashing standards apply to any system holding practitioner or client credentials. See our IRS WISP requirements guide and FTC Safeguards recordkeeping guide for what to document.
Healthcare organizations under the HIPAA Security Rule must address encryption for electronic protected health information under §164.312, with written justification for any addressable specification they do not deploy. Practices can review gaps with our HIPAA guidance for dental and specialty offices and plan recovery with ransomware protection. Financial services firms under PCI DSS 4.0 must encrypt cardholder data at rest (Requirement 3.5.1) and in transit (Requirement 4.2.1) and salt stored password hashes (Requirement 8.3.2). Legal questions about any of these obligations belong with your counsel.
Next step for regulated firms
A security review can confirm your encryption, password hashing, and key storage meet HIPAA, IRS, or PCI expectations before an audit does.
Quantum risk and cryptographic hygiene
Quantum computers change the risk picture unevenly. Running Shor's algorithm, a large enough quantum computer could break RSA, Diffie-Hellman, and ECC; today's hardware cannot, but projections put practical risk 10 to 30 years out, and the 'harvest now, decrypt later' threat means adversaries may already be storing encrypted data to open once capable hardware exists. NIST finalized its first post-quantum standards in August 2024, including FIPS 203 (ML-KEM), FIPS 204 (ML-DSA), and FIPS 205 (SLH-DSA), so design new systems for cryptographic agility, the ability to swap algorithms without a rebuild. Hash functions age better: Grover's algorithm only halves effective strength, leaving SHA-256 at about 128-bit security, which is still considered sound.
Day to day, the failures are operational, not mathematical. Keep encryption keys out of source code and away from the data they protect, store them in a key management system or hardware security module, rotate them on a schedule, and restrict access to least privilege. Keep an inventory of the algorithms you run, track NIST and CISA deprecation notices, and migrate off retired ones on a documented plan.
Get Your Free Cybersecurity Evaluation
Our team reviews your encryption, password hashing, and key storage, then gives you clear, prioritized fixes to reduce risk and meet compliance requirements.
Frequently Asked Questions
Encryption is reversible: data encrypted with a key can be decrypted back to its original form with the correct key. Hashing is irreversible: it converts input into a fixed-length digest that cannot be reversed to reveal the original. Use encryption when you need to retrieve the data later, and use hashing when you only need to verify that data matches a known value, such as confirming a password without storing it.
If you encrypt passwords, your system has to store the decryption key, and anyone who obtains that key through a breach, insider threat, or misconfiguration can decrypt every password at once. With hashing there is no key to steal: you verify a password by hashing the user's input and comparing it to the stored hash. Because the original password never needs to be recovered, storing passwords with reversible encryption is considered a security failure even when the encryption itself is strong.
In practice, no. Modern algorithms like AES-256 are designed so that decrypting without the correct key would take computational resources far beyond what exists today. Weak key management, though, can undermine strong encryption: storing keys insecurely, hardcoding them in source code, using short keys, or reusing keys inappropriately all put the data at risk. The security of encrypted data depends on both the algorithm and how well the keys are protected.
Hashing is a cryptographic operation that produces an irreversible digest used to verify integrity or authenticate data. Base64 encoding simply converts binary data into ASCII text so it can travel over text-based protocols like email or JSON APIs. Base64 is instantly reversible with no key and provides zero security, so treating it as protection is a well-documented mistake that leaves data fully exposed.
A rainbow table is a precomputed list of hashes for common passwords. Without salting, two users with the same password produce the same hash, so an attacker can look it up and recover the password instantly. A salt is a unique random value added to each password before hashing, so even identical passwords produce different hashes. Because a single precomputed table cannot cover every salt, the attacker has to attack each password individually, which is far slower.
Compare the operating outcome, not just the price
Choose the option that makes ownership and total cost clear
A useful comparison shows what is included, who watches and responds, where extra work remains, and which costs appear after the headline quote.
People also look for
Keep exploring Technical security
Explore deeper guidance on password storage, encryption, testing, frameworks, and security engineering.
- Common question: best password hashing algorithmCompare password hashing algorithmsCompare Argon2id, bcrypt, scrypt, and PBKDF2 for secure credential storage.
- Common question: MITRE ATT&CK frameworkUse the MITRE ATT&CK frameworkConnect attacker behavior to detection, investigation, and security-control decisions.
- Common question: penetration testing explainedUnderstand penetration testingSee what a test should cover, what the results mean, and where testing fits in risk management.
- Common question: secure software development assessmentAssess secure software developmentReview design, development, dependency, and deployment practices through a security lens.
- Common question: OSINT for cybersecurity beginnersStart learning defensive OSINTUnderstand how public information can support investigation and exposure awareness.



