Password Hashing: How It Works and Why It Matters
What Is Password Hashing?
Password hashing is the practice of running a password through a one-way mathematical function and storing only the resulting fixed-length string, called a hash, or digest. When a user logs in, the system hashes the submitted password and compares the result with the stored value. The original password never needs to be saved, so a stolen database does not hand attackers a list of working logins.
The one-way property is what separates hashing from simple obfuscation. A good hash function makes it computationally impractical to reverse the digest into the original input, and even a one-character change in the password produces a completely different output. Security teams rely on these properties to protect accounts when other defenses fail.
General-purpose hash functions are not all suitable for this job. Message Digest 5 (MD5) is a 128-bit algorithm developed in 1992 and is now considered insecure, and its speed is exactly what makes it a poor fit for passwords. Purpose-built password hashing algorithms deliberately run slowly and consume memory, which raises the cost for anyone trying to guess passwords at scale. The rest of this article explains how the process works, which algorithms to choose, and how threat intelligence helps when hashed credentials leak anyway.
Why Password Hashing Matters?
Every application that stores credentials eventually has to assume that its database could be copied. Attackers target password stores through Structured Query Language (SQL) injection, misconfigured backups, and compromised insiders, and once they hold the data, the strength of the hashing scheme decides how many accounts fall. Weak or unsalted hashes can be cracked in hours, while well-tuned algorithms make each guess expensive. Security leaders therefore treat the storage scheme as a measurable control, review it during audits, and retest it whenever hardware or attacker tooling changes.
The damage rarely stays inside one service. Over half of people reuse passwords across sites, so a cracked hash from a small forum can unlock corporate email, cloud consoles, and virtual private network (VPN) accounts. This is how a single data breach becomes a credential stuffing campaign against unrelated organizations. Strong hashing slows that chain at its first link.
Regulators and auditors also expect sound storage practices. Frameworks and breach notification rules treat plaintext or trivially hashed passwords as a serious failure, and the cost of exposure is wider than the stolen accounts.
The table below pairs common risks with practical defensive controls.

How Password Hashing Works?
The flow has three stages. At registration, the application generates a random salt, combines it with the password, and feeds the pair into a slow hashing function. It then stores the salt and the digest together. At login, the application retrieves the salt for that account, repeats the computation on the submitted password, and compares the outputs using a constant-time comparison to avoid timing leaks.
Salting is the step that defeats precomputed attacks. A salt is a unique random value added to each password before hashing, so two users with the same password end up with different digests. Without salts, attackers can use rainbow tables, which are large precomputed lookup tables that Enzoic notes can be hundreds of gigabytes in size for common algorithms. With unique salts, an attacker must crack each hash separately.
Key stretching adds a second layer. The algorithm repeats its internal work thousands of times, or uses large amounts of memory, so that each guess costs real time and hardware. The setting that controls this effort is called the work factor, and it should rise as hardware gets faster.

Some organizations add a pepper, a secret value stored outside the database, such as in a hardware security module or key management service. A pepper means that stealing the database alone is not enough to start cracking.
Choosing a Password Hashing Algorithm
Speed is the enemy here. Fast hashes such as MD5, Secure Hash Algorithm 1 (SHA-1), and plain SHA-256 let modern graphics processing units (GPUs) test billions of guesses per second, which makes dictionary attacks and brute-force attacks highly effective. Password hashing algorithms flip that logic by being slow and, in newer designs, memory-hungry.
bcrypt was developed in 1999 and built specifically for password hashing, and scrypt followed in 2009 with a memory-intensive design. Argon2 won the Password Hashing Competition in 2015 and is now the common first choice for new systems, usually in its Argon2id variant. Password-Based Key Derivation Function 2 (PBKDF2) remains widely used where compliance requires it.
| Algorithm | Year | Strength | Typical Guidance |
|---|---|---|---|
| MD5 | 1992 | Very fast, no longer collision resistant | Never use for passwords |
| bcrypt | 1999 | Adaptive cost factor, widely supported | Cost factor of at least 12 |
| PBKDF2 | 2000 | Standards-friendly, processor-bound only | At least 100,000 iterations |
| scrypt | 2009 | Memory-hard design | Tune memory and CPU cost together |
| Argon2id | 2015 | Memory-hard, resists GPU attacks | Prefer for new builds |
SuperTokens recommends a bcrypt cost factor of at least 12 and at least 100,000 PBKDF2 iterations. Defaults age quickly, since a bcrypt cost of 10 now often takes only milliseconds on modern hardware. Teams should benchmark on their own servers, aim for a delay that users barely notice, and plan to rehash passwords at next login when they raise the work factor.
Hashing Versus Encryption and Common Attacks
Hashing and encryption are often confused, but they serve different goals. Encryption is reversible by anyone holding the key, which makes it right for data that must be read again, such as files in transit. Hashing is one-way by design, which makes it right for passwords that only need to be verified. Storing passwords with reversible encryption creates a single key whose theft exposes every account.
Attackers who obtain a hash dump rely on a few well-known methods. Dictionary attacks hash lists of common passwords and leaked credentials and compare them with the stolen digests. Brute-force attacks try every possible combination up to a given length. Rainbow table attacks look up precomputed hashes, and they fail against properly salted hashes. Credential stuffing then replays cracked pairs against other services.
Hashing cannot rescue a weak password. If a user picks a common phrase, a dictionary attack finds it quickly regardless of the algorithm. For that reason, strong storage should be paired with length requirements, blocklists of known compromised passwords, and multi-factor authentication. Teams that want an extra safety net also watch for exposed credential sets that circulate after breaches elsewhere. Regular password audits against known leaked lists help find accounts that still use risky passwords before an attacker does, and they give administrators evidence for policy changes.
How SOCRadar Threat Intelligence Addresses Password Hashing?
Good hashing limits the harm of a breach, but it cannot tell you that your users’ credentials are already circulating. SOCRadar Threat Intelligence fills that gap by watching the places where stolen data shows up. Advanced Dark Web Monitoring (ADWM) tracks Dark Web forums, marketplaces, and paste sites for leaked credential dumps that mention your domains, so security teams learn about exposure before attackers use it.
When a dump contains hashes, analysts can assess how quickly they are likely to be cracked based on the algorithm and the presence of salts, then prioritize resets for the accounts at highest risk. Cyber Threat Intelligence adds context about the threat actors selling or reusing the data, which helps teams judge how urgent a response should be.
The Attack Surface Management (ASM) solution complements this by finding exposed login portals, forgotten admin panels, and leaked configuration files that could reveal how passwords are stored. Brand Protection and Digital Risk Protection (DRP) extend coverage to phishing pages that harvest passwords directly, bypassing hashing entirely, and SOCRadar offers Takedown services to remove them. Together these capabilities give defenders a view that begins where the password database ends. Analysts can also feed findings into incident response playbooks, so a leaked hash triggers a defined reset and notification process rather than an ad hoc scramble.
Key Takeaways
- Store passwords only as salted hashes produced by a slow, purpose-built algorithm such as Argon2id or bcrypt
- Use a unique random salt per password and consider a pepper kept outside the database
- Tune the work factor on your own hardware and rehash at login as it rises
- Pair hashing with blocklists, multi-factor authentication, and credential exposure monitoring
Frequently Asked Questions
What Is the Difference Between Password Hashing and Encryption?
Hashing is a one-way process that cannot be reversed, while encryption can be undone with the right key. Passwords only need to be verified, so hashing is the safer choice for storage.
What Does a Salt Do in Password Hashing?
A salt is a unique random value added to each password before hashing. It makes identical passwords produce different digests and blocks rainbow table attacks, forcing attackers to crack each hash individually.
Which Password Hashing Algorithms Are Recommended Today?
Argon2id is the common first choice for new systems, with bcrypt, and scrypt as proven alternatives. PBKDF2 is acceptable where standards require it, and MD5 and SHA-1 should never be used for passwords.
How Do Attackers Crack Password Hashes After a Breach?
They run dictionary attacks with lists of common and leaked passwords, brute-force attacks across possible combinations, and rainbow table lookups against unsalted hashes. GPUs make fast hashes especially easy to crack.
Does Hashing Make Weak or Reused Passwords Safe?
No. A weak password falls to a dictionary attack even with a strong algorithm, and reused passwords carry risk across sites. Combine hashing with blocklists, multi-factor authentication, and credential monitoring.
Intelligence in your inbox every Thursday.
Join 30,000+ security professionals reading SOCRadar research.
Subscribe