Security

Bcrypt vs SHA-256

BcryptVSSHA-256

Bcrypt and SHA-256 are both hash functions, but they're designed for fundamentally different purposes - SHA-256 is a fast, general-purpose cryptographic hash, while bcrypt is deliberately slow and specifically built for hashing passwords securely.

!
Quick take

SHA-256 should never be used alone to hash passwords - its speed, which is exactly what makes it good for checksums and signatures, is precisely what makes it dangerous for passwords, since it lets an attacker attempt billions of guesses per second on stolen hashes.

Side by side

 BcryptSHA-256
Designed forPassword storage specificallyGeneral-purpose hashing (checksums, signatures, etc.)
SpeedDeliberately slow (configurable cost factor)Very fast
Built-in saltingYes - automatic, unique salt per hashNo - must be added manually
Resistance to brute forceHigh - slowness makes guessing attacks expensiveLow on its own - speed helps attackers, not defenders
Output includes salt & costYes - all encoded in the hash string itselfNo - salt must be stored and managed separately
Appropriate for passwords?Yes - purpose-built for thisNo - too fast, enables rapid brute-forcing

The verdict

SHA-256 should never be used alone to hash passwords - its speed, which is exactly what makes it good for checksums and signatures, is precisely what makes it dangerous for passwords, since it lets an attacker attempt billions of guesses per second on stolen hashes. Bcrypt (or similar purpose-built algorithms like Argon2) should always be used for password storage instead.

Frequently asked questions

01Why is fast hashing bad for passwords specifically?

Because attackers with a stolen password database try to guess the original password by hashing huge numbers of candidates - a fast hash function lets them attempt billions of guesses per second, while a deliberately slow one like bcrypt limits that to a small fraction of that rate.

02Can I make SHA-256 safe for passwords by adding a salt myself?

A salt helps prevent precomputed rainbow-table attacks, but it doesn't address SHA-256's fundamental problem: its raw speed still allows fast brute-forcing of any individual password once its salt is known.

03Is bcrypt still considered secure today?

Yes - bcrypt remains a solid, widely-trusted choice, though newer algorithms like Argon2 (winner of the Password Hashing Competition) are sometimes recommended for new systems for their additional memory-hardness properties.