SHA-256 is not a secure password hashing algorithm (2024)

SHA-256 is not a secure password hashing algorithm. SHA-512 neither, regardless of how good it has been salted. Why not? Because both can be computed in the billions per minute with specialised hardware. If you are surprised to hear that you should continue reading...

What makes a good password hashing algorithm?

A password hash is the very last line of defence. Its only purpose is to prevent an attacker from gaining total control of a user when all other measures of security have been broken. This usually means to prevent the attacker from using the compromised data to access users' data on other websites, which could happen when a user re-uses a password. It is extremely important that a good hashing algorithm will resist all attempts of cracking it, at least for a significant period of time.

Since the attacker is in control of the raw user data there is nothing which can be done to prevent a crude brute force attack. However, this is not an easy undertaking and there are measures which can be put into place to prolong the attack and jeopardise its feasibility.

A good password hashing algorithm removes the slightest chance of a shortcut, leaving a brute force attack as the only attack surface and puts other barriers in place.

One-way functions

First of all this means that a password must always be stored with a cryptographic one-way function. If a password has been encrypted with an algorithm which allows decryption then there is no guarantee that an attacker has not already gained access to the secret key and immediately bypassed all gates of security.

Therefore encryption algorithms such as AES and RSA are not secure storage mechanisms for a password. The use of a one-way hash function is mandatory.

Pre-image and collision attacks

A password hash also needs to resist so called pre-image and collision attacks. In simple words it should not be possible to methodically find a value which can be computed to a given hash value. This crosses out hash functions such as MD5 and SHA-1 which have been proven to be vulnerable to such attacks.

Lookup tables and password salting

Another shortcut are lookup tables. A lookup table is a pre-computed table with hash values derived from commonly used passwords and dictionary entries. An attacker can easily match up a lookup table with the compromised hash values and look up the underlying plain text password. This is where the concept of salting comes into play.

A salt is a piece of text of certain length and complexity which is added to the original value before computing a hash. The idea is that the salt itself is random enough to generate a hash which will not exist in a pre-computed lookup table.

The salt is usually stored in plain text next to the hash value. This is required to allow a genuine login scenario with the original password. It doesn't matter if an attacker can see the salt, because it still invalidates a pre-computed lookup table.

Random salt per user

It is good practice to generate a random salt per user. If the same salt has been shared among all users then an attacker can quickly generate a new lookup table and is back at square one. However, if every user has an individual salt then it becomes significantly more difficult.

Additionally a random salt per user prevents the use of reverse lookup tables. A reverse lookup table is similar to a lookup table except that it matches up the password of multiple users at once. This is possible because many users pick the same (simple) password without knowing it.

Key-stretching algorithms

By using salts and eliminating the possibility of pre-computed lookup tables an attacker is forced to go down the route of a brute force attack. Even though it is extremely difficult it is not impossible. High end hardware with fast GPU can compute billions of hashes per minute.

How can one protect a password from being brute force attacked like this? The idea is to slow down the hashing function. This technique is called key stretching and is a specially crafted algorithm which is very hardware intensive. Such algorithms usually come with an iteration factor which needs to be carefully adjusted to the hardware used on a web server. This is the currently recommended way of storing passwords.

Popular key-stretching algorithms are:

The .NET framework has native built in support for PBKDF2 which comes in form of the Rfc2898DeriveBytes class. There is also an open source library for bcrypt in .NET.

Summary

As you can see good password hashing is more than just sticking a salt at the end of a password and shoving it into the SHA-256 hash function. In practical terms this is as bad as using MD5.

Correct password hashing is not too complicated either, but if it could be avoided all together it would be even better. There is always the option of defering the password handling to a 3rd party by using single sign-on options from trusted authorities such as Google, Facebook or Twitter.

If you have to do it yourself you should follow the guidelines from above and use a key derivation algorithm (=key stretching) in combination with a random salt per user and stick with the native implementation. Don't try to create your own algorithm as you will only get it wrong and end up with a hash function which can be easily parallelised on the CPU and potentially make it even worse.

Last but not least you should always encourage your users to chose strong and unique passwords and not limit them in doing so.

SHA-256 is not a secure password hashing algorithm (2024)

FAQs

Why is SHA-256 not good for password hashing? ›

A SHA256 hash cannot be reversed or “cracked”, but in many cases it just doesn't need to be. An attacker will simply use a list (called a rainbow table) of hashes to compare to the stolen data.

What is the problem with SHA-256? ›

Advantages and Disadvantages

SHA-256 provides a high level of security, making it practically impossible to derive the original data from its hash value. Although rare, there is a theoretical possibility of hash collisions, where two different inputs produce the same hash value.

What is the SHA-256 hash of the password? ›

The SHA-256 hash can be used as a secure 64 char password. If the purpose is to compare two raw source files then one can generate the hash and compare them. SHA-256 generates almost unique 32 bit hash. With recent computational advancements, it has become possible to decrypt SHA-256 hashes.

Is SHA-256 still used? ›

The secure hash algorithm with a digest size of 256 bits, or the SHA 256 algorithm, is one of the most widely used hash algorithms. While there are other variants, SHA 256 has been at the forefront of real-world applications.

What is better than SHA-256? ›

SHA-512 offers better security than SHA-256, but it is not widely used as of now.

Is hashing a password enough? ›

But, password hashing alone isn't enough. Password salting adds another layer of security that blocks the most common forms of attack vectors, adding a level of unpredictability to further lower the chance of data breaches.

Why SHA-256 cannot be decrypted? ›

Ans: Since SHA-256 is not an Encryption Function, is a Hashing Function, it cannot be decrypted. What it means is probably reversing it. In that case, SHA256 cannot be reversed because it's a one-way hashing function. Reversing it would cause a preimage attack, which defeats its design goal.

How long does SHA-256 take to crack? ›

SHA-256 cracking performance with CPU machine. Using uppercase only character (u) it takes 15sec for 6-character long password HELLO to crack where 8-character long password “MYSECRET” takes 20 mins and it finishes checking all the combination of 8 characters roughly in 38 mins.

How do I block SHA-256? ›

Steps for blocking Sha-256 on FMC
  1. Add sha-256 to Objects >> File List >> Custom-Detection-List.
  2. Add File List (somehow) to Policies >>Access Control >> Malware & File >> Malware Block.
  3. Add Malware Block to Policies >> Access Control >> My production Access Control List.
Mar 14, 2020

Is SHA-256 good enough? ›

SHA-256 is secure due to its 256-bit hash output, making it exponentially more complex and harder to crack than SHA-1. This complexity helps secure against brute force attacks and collision vulnerabilities, making it a more secure hashing algorithm.

Can we decrypt SHA-256 password? ›

SHA-256 is a cryptographic (one-way) hash function, so there is no direct way to decode it. The entire purpose of a cryptographic hash function is that you can't undo it.

Can SHA-256 be reversed? ›

Cryptographic Hash functions cannot have the reverse since they are one way functions. Many asked the inverting SHA256 since the Bitcoin uses SHA256d.

Why is SHA-256 bad for passwords? ›

A good hash algorithm makes it impossible to reverse the hash value to compute the original text. However, passwords are very, very short. By making a guess at a password, the attacker can compare the output of his SHA-256 against the SHA-256 that he finds in the database.

Does Google use SHA 256? ›

Google Authenticator now supports SHA256 and SHA512 · Issue #27349 · keycloak/keycloak · GitHub.

Does SHA-256 require a key? ›

It is not an encryption method. It is a method of creating what's called a “hash code”. No, SHA256 does not require a key.

Is SHA-256 a weak hashing algorithm? ›

SHA-256 is secure due to its 256-bit hash output, making it exponentially more complex and harder to crack than SHA-1. This complexity helps secure against brute force attacks and collision vulnerabilities, making it a more secure hashing algorithm.

Is SHA-256 not safe? ›

I understand that sha256 is not good for hashing passwords because it's too fast, so attackers can brute-force the output of commonly used passwords. I recently used Google Ads API and other ad platforms to upload conversions. A hashed (using sha256) user email is included in the uploaded conversion.

What is the best hash for passwords? ›

While Argon2id should be the best choice for password hashing, scrypt should be used when the former is not available. Like Argon2id, scrypt has three different parameters that can be configured: the minimum CPU/memory cost parameter (N), the blocksize (r) and the degree of parallelism (p).

Top Articles
Here’s What’s Actually in the Fine Print of Your Life Insurance Policy
I want whole life insurance, but my husband wants term life insurance, so we asked an insurance expert what to do
Nco Leadership Center Of Excellence
Chatiw.ib
Junk Cars For Sale Craigslist
Mychart Mercy Lutherville
Wannaseemypixels
Miles City Montana Craigslist
Kentucky Downs Entries Today
CSC error CS0006: Metadata file 'SonarAnalyzer.dll' could not be found
Devourer Of Gods Resprite
PGA of America leaving Palm Beach Gardens for Frisco, Texas
Detroit Lions 50 50
Culos Grandes Ricos
Identogo Brunswick Ga
Worcester On Craigslist
Current Time In Maryland
Connect U Of M Dearborn
Milspec Mojo Bio
Darrell Waltrip Off Road Center
Papa Johns Mear Me
Lacey Costco Gas Price
Marokko houdt honderden mensen tegen die illegaal grens met Spaanse stad Ceuta wilden oversteken
Downtown Dispensary Promo Code
Ghid depunere declarație unică
Gus Floribama Shore Drugs
Fairwinds Shred Fest 2023
Scat Ladyboy
Rock Salt Font Free by Sideshow » Font Squirrel
Www.craigslist.com Syracuse Ny
Netherforged Lavaproof Boots
Tendermeetup Login
Quake Awakening Fragments
The Boogeyman Showtimes Near Surf Cinemas
Shih Tzu dogs for sale in Ireland
Hingham Police Scanner Wicked Local
Hindilinks4U Bollywood Action Movies
The Minneapolis Journal from Minneapolis, Minnesota
NHL training camps open with Swayman's status with the Bruins among the many questions
Xxn Abbreviation List 2023
Craigslist Farm And Garden Reading Pa
Amc.santa Anita
Tattoo Shops In Ocean City Nj
Stosh's Kolaches Photos
Ferhnvi
Backpage New York | massage in New York, New York
Devotion Showtimes Near Showplace Icon At Valley Fair
Colin Donnell Lpsg
Christie Ileto Wedding
Suppress Spell Damage Poe
Mazda 3 Depreciation
Latest Posts
Article information

Author: Clemencia Bogisich Ret

Last Updated:

Views: 6420

Rating: 5 / 5 (60 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Clemencia Bogisich Ret

Birthday: 2001-07-17

Address: Suite 794 53887 Geri Spring, West Cristentown, KY 54855

Phone: +5934435460663

Job: Central Hospitality Director

Hobby: Yoga, Electronics, Rafting, Lockpicking, Inline skating, Puzzles, scrapbook

Introduction: My name is Clemencia Bogisich Ret, I am a super, outstanding, graceful, friendly, vast, comfortable, agreeable person who loves writing and wants to share my knowledge and understanding with you.