What is Password Hashing and Salting? (2024)

Security is often not top of mind when creating customer-facing applications. But in a landscape of continual data breaches of major corporations like T-Mobile and Google, companies must be vigilant to adhere to security best practices.

Processes like password salting and hashing are fundamental to the security posture of your apps. Understanding these broader security concepts is the first step in avoiding major breaches to your database, and loss of consumer trust.

In this post, we will explore the basics of encryption and cryptography, the mechanics of password hashing, and the application of salted passwords to uncover why security experts care about these topics.

Cryptography & Encryption

To understand why salted passwords were created, and how they work, we first need to explore the importance of cryptography and encryption. Some definitions:

Cryptography is defined as the practice and study of techniques of secure communication between two parties in the presence of a 3rd party.

Encryption is a technique of cryptography wherein a message is encoded such that only authorised parties can read it, converting plaintext into an unintelligible series of letters/numbers.

Cryptography and encryption are crucial today because of their role in helping protect against bad actors from around the world. With cybercrime becoming the fastest-growing crime in the U.S., and costing the global economy more than $450 billion in 2016, employing best practices of encryption and cryptography are more important than ever.

If all information were plaintext and had no encryption or cryptography surrounding it, sensitive materials like password information, health records (PII), and even bank account information (PIFI) could be stolen and sold to the highest bidder. One of the first steps of basic security hygiene is to not store sensitive data in plaintext—especially passwords. This is where password hashing comes in.

What is Password Hashing?

Password hashing is defined as putting a password through a hashing algorithm (bcrypt, SHA, etc) to turn plaintext into an unintelligible series of numbers and letters. This is important for basic security hygiene because, in the event of a security breach, any compromised hashed passwords are unintelligible to the bad actor. As a result, the theft of this information is considerably more difficult.

Below is an example of a few words going through the hashing process.

What is Password Hashing and Salting? (1)

What is Password Salting?

Password hashing is a key step to protecting your users on the backend, but it’s not infallible because it hashes in a consistent way. This means it is predictable and can be beaten by dictionary attacks or rainbow table attacks.

“Hello”, for example, will always equal to the same combination of letters and numbers, and therefore can be guessed through brute force. One way of protecting against this is by adding password salt or using salted passwords.

Salting is the act of adding a series of random characters to a password before going through the hashing function. How does it work? Let’s take a look:

What is Password Hashing and Salting? (2)

As you can see in the image above, we’re adding a series of random numbers and letters to the original “password” to result in a different hash function each time. This way, we protect against the flaw of the hash function by having a different hashed password each time.

Where should salted passwords be stored?

In terms of how this works in the IT infrastructure, salts have to be stored in a database along with the user password, as illustrated below. Salts are recommended to be random and unique per login to mitigate attacks using rainbow tables of pre-computed hashes. While an attacker could still re-compute hashes of common password lists using a given salt for a password, a way to provide additional defense in depth is to encrypt password storage at rest, preferably backed by a HSM or cloud key management service like AWS KMS.

What is Password Hashing and Salting? (3)

Beginning your journey

That’s how salted passwords work. But that’s only the tip of the iceberg for securing your customer-facing applications. Understanding these concepts around cryptography and encryption is a lengthy process, and when creating customer-facing applications, creating these workflows are not easy.

How Okta can help

Today, Okta supports the use of password hashing and salting, and we employ industry best practices to best protect your customer data. We support standardised hashing algorithms like bcrypt to best secure your customer passwords and allow for secure authentication.

To read more on protecting your customer’s data, check out the following resources:

Password Encryption: How Do Password Encryption Methods Work?

When you store your customer data with Okta, we never allow for passwords to be exfiltrated with restrictive admin policies. This prevents a single point of vulnerability due to privileged access, and protects against account takeovers. Click here tolearn more about additional steps you can take to keep your customers’ accounts secure.

What is Password Hashing and Salting? (2024)

FAQs

What is Password Hashing and Salting? ›

Hashing is a one-way process that converts a password to ciphertext using hash algorithms. A hashed password cannot be decrypted, but a hacker can try to reverse engineer it. Password salting adds random characters before or after a password prior to hashing to obfuscate the actual password.

What is password hashing for? ›

Password hashing turns your password (or any other piece of data) into a short string of letters and/or numbers using an encryption algorithm. If a website is hacked, password hashing helps prevent cybercriminals from getting access to your passwords.

What is hashing and salting in .NET password? ›

Encrypting user details. We want to take the users' personal data and store it in the database using a method called salting and hashing. We salt the data to be encrypted and, in doing so, make it more complex and more random. A common way to crack encrypted data is by using lookup tables or 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.

What is difference between encryption and hashing? ›

Basically, encryption is the process of scrambling plaintext into unreadable ciphertext, which you can decrypt with a relevant key, while hashing turns plain text into a unique code, which can't be reverted into a readable form.

What is an example of a password hashing? ›

For example, the input "password" might produce the hash "5f4dcc3b5aa765d61d8327deb882cf99", while the input "passw0rd" might produce the hash "6c569aabbf7775ef8fc5705a9f1f9b2f". Hashing is irreversible, meaning that you cannot recover the original input from the hash.

What is password salting? ›

With password salting, a random piece of data is added to the password before it runs through the hashing algorithm, making it unique and harder to crack. When using both hashing and salting, even if two users choose the same password, salting adds random characters to each password when the users enter them.

What is an example of a salt and hash password? ›

If we hash the password, “admin,” we get: 21232f297a57a5a743894a0e4a801fc3. If two users both used “admin”, they would have identical hashes without salting. If we add a randomly generated salt string, “E4OAovh7rb” to the password, the new hash we get is: 24e231fcd0b20b0e3fd3dccf8b160c29.

How are hashed passwords checked? ›

Whenever a user logs into the software or app, the provided value will first be hashed and then checked with the hash stored in the database to verify the user's identity. In this way, even if hackers manage to obtain the hash, they cannot use it to log in.

Should passwords be hashed or encrypted? ›

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 do hackers do with hashed passwords? ›

If they successfully crack a hashed password, they may gain unauthorized access to user accounts and steal sensitive information. They may also use the stolen information for ransomware attacks, where the organization has to pay large sums of money to regain the sensitive data hackers have stolen and encrypted.

Can two passwords have same hash? ›

If a match is found, the password then can be deduced. Two different hash functions can produce the same hash; however, the risk of this happening is extremely low.

How hard is it to crack a hashed password? ›

Dictionary lists and other tools make this task a bit easier for an attacker in a hybrid attack, but the time needed to crack a hashed password can get astronomical quickly. Different hashing algorithms take different amounts of time for password cracking software and hardware to crack.

What is the difference between hashing and salting? ›

Hashing is a one-way function where data is mapped to a fixed-length value. Hashing is primarily used for authentication. Salting is an additional step during hashing, typically seen in association to hashed passwords, that adds an additional value to the end of the password that changes the hash value produced.

What is an example of hashing? ›

Hashing is designed to solve the problem of needing to efficiently find or store an item in a collection. For example, if we have a list of 10,000 words of English and we want to check if a given word is in the list, it would be inefficient to successively compare the word with all 10,000 items until we find a match.

What is salting in cyber security? ›

In cryptography, a salt is random data fed as an additional input to a one-way function that hashes data, a password or passphrase. Salting helps defend against attacks that use precomputed tables (e.g. rainbow tables), by vastly growing the size of table needed for a successful attack.

What is the purpose of hashing in security? ›

Hashing is a one-way mathematical function that turns data into a string of nondescript text that cannot be reversed or decoded. In the context of cybersecurity, hashing is a way to keep sensitive information and data — including passwords, messages, and documents — secure.

Do I need to hash passwords? ›

Password hashing makes storage and management more secure, and applies to both salted and unsalted passwords. Salted passwords that are also hashed make it harder for bad actors to crack passwords at scale.

Why is hashing used in security? ›

Hashing is a data security technique used to convert data values into alternate, unique identifiers called hashes for quick and secure access. Hashing can be used for data security because the one-way process prevents access to or tampering with the source data.

Top Articles
Latest Posts
Article information

Author: Jonah Leffler

Last Updated:

Views: 6518

Rating: 4.4 / 5 (45 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Jonah Leffler

Birthday: 1997-10-27

Address: 8987 Kieth Ports, Luettgenland, CT 54657-9808

Phone: +2611128251586

Job: Mining Supervisor

Hobby: Worldbuilding, Electronics, Amateur radio, Skiing, Cycling, Jogging, Taxidermy

Introduction: My name is Jonah Leffler, I am a determined, faithful, outstanding, inexpensive, cheerful, determined, smiling person who loves writing and wants to share my knowledge and understanding with you.