Hashing: What You Need to Know About Storing Passwords (2024)

Cybersecurity isn’t always a battle to keep hackers out at all costs. Sometimes it’s actually about making the costs just not worth the effort. This is particularly true when it comes to how passwords are stored on your server. Let’s take a look at how to make it more unreasonably costly to the hacker who just compromised the server that holds user passwords.

Storing Passwords In Plaintext

Storing passwords in plaintext is a major cybersecurity faux pas. For the hacker, it’s like winning the lottery. They get the keys to your system. And because most people reuse passwords, even a low value system may end up jeopardizing your highest value data.

The obvious risk of storing passwords in plaintext doesn’t mean some of the largest and most data-rich companies in the world don’t do it. Social media giant, Facebook, revealed that it had stored “hundreds of millions” of Facebook users’ passwords in plaintext. These plaintext passwords were accessible to thousands of Facebook employees, but Facebook maintains they have found no evidence that this access has been abused. Google has also disclosed a similar case of using plaintext passwords.

Despite repeated warnings and obvious danger,s passwords are still being stored in plaintext.

Using Basic Password Hashing

Password hashing add a layer of security. Hashing allows passwords to be stored in a format that can’t be reversed at any reasonable amount of time or cost for a hacker.

Hashing algorithms turn the plaintext password into an output of characters of a fixed length. The hash output will look nothing like the original password and the length of the hash will be the same regardless of the length of the plaintext password.

For example, using a simple MD5 hash generator with the password “Dragon” produces this output:

583f4be146b6127f9e4f3f036ce7df43

This hash value can be stored on the server instead of the plaintext password. The plaintext is then only used in memory during the login process. When a user enters their password at login, the server immediately converts the plaintext using the same algorithm so it can compare the hash value to what is stored on the server.

The goal of hashing is to make the computational costs of reverse engineering hashes too costly in terms of time or dollars for the computing power to be worthwhile.

Why Hashes Should Be Costly For Hackers

Hashes are generally difficult to reverse engineer because there is nothing in the hash value that gives a clue about the original plaintext value. Hash algorithms are designed in a way that even a small change to the input will produce a vastly different output.

As we discussed, the MD5 hash of the password “Dragon” produces this output:

583f4be146b6127f9e4f3f036ce7df43

If we change one letter in that password, making it “Dragons”, we get the following output:

c880d3c8945e8fc312e989bd90a2cbf0

As you can see, these are entirely different hashes with no way to turn hash back into plaintext. However, with enough time and computer power, a hacker could run every possible combination of characters into the hash algorithm to find the one password that produces the hashed value.

Unfortunately, computational power has become dramatically cheaper. A typical cracking rig with 8 NVIDIA 1080ti graphics card can run through 720 trillion MD5 hashes per hour.

This decrease in the cost of computing power now makes MD5 hashes completely inappropriate for secure password storage. We need to consider other hashing algorithms.

A Closer Looking At Hashing Algorithms

There are many different hashing options, and not all hashing algorithms are equal when it comes to the cost they impose on hackers.

Let us take a look at just a few of the hashing algorithms.

MD5

  • As discussed, MD5’s downfall when it comes to passwords was that it was too fast and also too popular. The speed made brute force attacks easier since large numbers of inputs can be quickly tested. The popularity of the function makes it attractive to hackers. At this point, anyone can find the password for an MD5 hash – just Google it.

MD5Crypt

  • MD5Crypt added extra functionality to MD5 in order to make it more resistant to brute force attacks. However, in 2012 the author of MD5Crypt, Poul-Hennin Kamp, declared it as insecure due to the speed of modern hardware. He said “[The] only problem with md5crypt is speed: it’s too fast.”

SHA-1

  • SHA-1 suffers from many of the same problems MD5 does. It’s very fast, it’s also experienced collision attacks, and it’s now considered unsafe. Faster computations now mean faster brute force attacks making SHA-1 inherently insecure at storing passwords.

BCrypt

  • Unlike SHA-1 and MD5, Bcrypt is designed to be slow, which is a good thing when it comes to password security because it limits the attacker’s ability to successfully perform brute force attacks. This slowed down hashing function makes cracking the hashes more infeasible because it is time-consuming and uses a lot of computing power.

Argon2

  • Argon2 maximizes resistance to GPU cracking attacks. It uses an “adaptive” one-way function which means it can be configured, using a “work factor”, to control how “hard” it is to complete.

Common Passwords Jeopardized Even Hard Hashes

Because people reuse the same passwords so often, hackers don’t have to guess every possible combination of characters. They only need a list of common, compromised passwords.

As a result of the many data breaches large and small, Cybercriminals now have access to billions of password choices humans have actually made. Looking at this data has shown the same password being reused again and again.

This knowledge allows hackers to easily generate the hashes for the most common passwords for even the most resource consuming hashes. This allows the hacker to “look-up” any hash to find the corresponding password.

Many organizations are modifying password policies to restrict common and compromised passwords. This solution involves the IT department taking up to date lists of compromised passwords to help users avoid selecting common passwords.

By eliminating the use of common, compromised passwords hackers have to revert to brute force guessing.

The Benefit of Adding Salt to Your Hash

There is another common approach to make reversing hashes harder. It involves adding random characters called salt to the user’s password. The salt value would be different for each user. When multiple users select the same plaintext password, each will end up having a completely different hash value stored on the server.

This frustrates the hacker and adds substantial costs to their hacking. The hacker would need to go through the same expenses of hash guessing exercise for each possible password with each user’s salt value.

However, a motivated hacker will be able to easily crack even hard hashes with salt when the user has chosen a very common password.

Bottomline

The goal of hashing is to strike the right balance for “hardness”. This means it’s not so slow to calculate that it affects user experience when they enter the password. But it also means that it’s really costly in terms of time and computing resources for attackers to figure out passwords if the database gets breached and the password hashes are released. This goal can be best achieved by selecting a modern hash algorithm and preventing users from selecting common, compromised passwords.

The post Hashing: What You Need to Know About Storing Passwords appeared first on Enzoic.

Recent Articles By Author

  • 4 Reasons Why Data Breaches Keep Happening to Organizations
  • Safer Internet Day 2023: Four Priorities
  • Back to School Means More Cyber Concerns

Hashing: What You Need to Know About Storing Passwords (2)More from Kim Jacobson

*** This is a Security Bloggers Network syndicated blog from Enzoic authored by Kim Jacobson. Read the original post at: https://www.enzoic.com/hashing-what-you-need-to-know-about-storing-passwords/

Hashing: What You Need to Know About Storing Passwords (2024)

FAQs

How is hashing used to store passwords? ›

Essentially, one string of characters in a password is transformed into a completely different string using a mathematical hashing function. Once a string (password) has been hashed, there's no way to reverse the process and each time a user logs in, their hashed password is compared with a recorded hashed value.

What is the best hashing algorithm for storing passwords? ›

To protect passwords, experts suggest using a strong and slow hashing algorithm like Argon2 or Bcrypt, combined with salt (or even better, with salt and pepper). (Basically, avoid faster algorithms for this usage.)

Is storing hashed passwords safe? ›

Hashing and encryption can keep sensitive data safe, but in almost all circ*mstances, passwords should be hashed, NOT encrypted. Because hashing is a one-way function (i.e., it is impossible to "decrypt" a hash and obtain the original plaintext value), it is the most appropriate approach for password validation.

What should be added to a password before hashing in order to store it securely? ›

A cryptographic salt is made up of random bits added to each password instance before its hashing. Salts create unique passwords even in the instance of two users choosing the same passwords. Salts help us mitigate hash table attacks by forcing attackers to re-compute them using the salts for each user.

What is an example of a password hashing? ›

For example, the SHA256 hash of "12345" is "5994471abb01112afcc18159f6cc74b4f511b99806da59b3caf5a9c173cacfc5" . If this hash is seen in a database, we know that the user's password is "12345" 2. In fact, there is an entire database of precomputed hashes which can be checked against. These are called rainbow tables.

Can a hashed password be reversed? ›

You can't "reverse" password hashes. You can't "unhash" or "dehash" passwords. You can't "reverse" or "invert" MD5, SHA256, bcrypt, SHA1, or similar hashes, salted or unsalted. You (usually) can't "decode" passwords, "decrypt" password hashes or "reverse" or "unscramble" password hashes at all.

Why is hashing better than encryption for passwords? ›

For example, a piece of plain text (a password, for example) can be turned into a hashed value, making it very hard to decipher. Hashing is a one-way process that can't be directly reversed (as opposed to encryption, which can be decrypted if you have the appropriate decryption key).

What is the difference between hashing and encryption? ›

Hashing vs Encryption – Hashing refers to permanent data conversion into message digest while encryption works in two ways, which can encode and decode the data. Hashing helps protect the integrity of the information and Encryption is used to secure the data from the reach of third parties.

What is the most secure hash method? ›

The most secure hashing algorithm currently is the SHA-2 (Secure Hash Algorithm 2) family of algorithms, which includes SHA-256, SHA-384, and SHA-512. These algorithms are considered to be secure and are used in many cryptographic applications.

Can hashed passwords be hacked? ›

It's difficult but sometimes possible for criminals to crack a hashed password. For example, a hacker could use a dictionary attack to run popular and predictable passwords through commonly used hashing algorithms, and see if the hashed result is in their leaked database.

What are the disadvantages of hashing passwords? ›

Limitations of Password Hashing

Hackers can try a brute-force attack by running random passwords through the hash function until they finally find a match. This is rather inefficient since the hash algorithms designed for securely storing passwords are designed to be slow, making the entire process tedious and long.

How do hackers crack hashed passwords? ›

Just as with brute forcing, if an attacker already has password hashes, they can use dictionary attacks to try and find a matching password offline.

Should passwords be hashed in frontend or backend? ›

Hashing passwords should primarily occur on the server side for security reasons. Storing plain text or hashed passwords on the client side can be risky. If passwords are hashed on the client side, the hashed value needs to be transmitted over the network, and if intercepted, it can be subjected to various attacks.

Why is salt crucial when it comes to storing hashed passwords? ›

Password salting increases password complexity, making them unique and secure without affecting user experience. It also helps prevent hash table attacks and slows down brute-force and dictionary attacks.

How do you store passwords? ›

The first, a low-tech solution, is to use a safe. Since passwords written on paper are only as secure as the paper itself, placing these backups in your safe is a practical way of adding security to your offline password storage process. The second, a high-tech solution, is using an offline password storage device.

What is the difference between SHA-256 and SHA 512? ›

The primary difference between SHA-256 and SHA-512 is the word size; SHA-256 uses 32-byte words whereas SHA-512 uses 64-byte words. There are also modified versions of each standard, known as SHA-224, SHA-384, SHA-512/224, and SHA-512/256.

What type of algorithm is used to hash the user password? ›

Commonly used hashing algorithms include Message Digest (MDx) algorithms, such as MD5, and Secure Hash Algorithms (SHA), such as SHA-1 and the SHA-2 family that includes the widely used SHA-256 algorithm.

What is the difference between SHA-256 and bcrypt? ›

The main difference between bcrypt and SHA256 is that bcrypt is created to calculate the hash as slowly as possible without hindering users, whereas SHA256 is designed to be computationally fast.

Which is better bcrypt or PBKDF2? ›

PBKDF2 is simple to implement but is considered to be less secure than more advanced algorithms. Bcrypt is more secure but is more resource-intensive. Scrypt is the most secure but is also the most resource-intensive.

Top Articles
Latest Posts
Article information

Author: Rev. Porsche Oberbrunner

Last Updated:

Views: 5671

Rating: 4.2 / 5 (73 voted)

Reviews: 88% of readers found this page helpful

Author information

Name: Rev. Porsche Oberbrunner

Birthday: 1994-06-25

Address: Suite 153 582 Lubowitz Walks, Port Alfredoborough, IN 72879-2838

Phone: +128413562823324

Job: IT Strategist

Hobby: Video gaming, Basketball, Web surfing, Book restoration, Jogging, Shooting, Fishing

Introduction: My name is Rev. Porsche Oberbrunner, I am a zany, graceful, talented, witty, determined, shiny, enchanting person who loves writing and wants to share my knowledge and understanding with you.