Salting

Salting in cryptography is a technique used to enhance the security of hashed passwords or other sensitive data. It involves adding a random value known as a "salt" to the data before hashing it. The salt is typically a random string of bits or characters and is unique for each piece of data being hashed.

The purpose of salting is to prevent attackers from using precomputed lookup tables (rainbow tables) or other techniques to quickly determine the original plaintext value from its hash. When the same plaintext is hashed with different salts, it produces different hash values, even if the plaintexts are identical. This makes it much more difficult and time-consuming for attackers to guess or crack the original values.

When a user creates an account or sets a password, the system generates a random salt and combines it with the user's password to produce the salted hash. The salt is then stored alongside the hash in the database. When the user attempts to log in, the system retrieves the salt and applies the same hash function to the entered password and the stored salt. If the resulting hash matches the one stored in the database, the password is considered correct, and the user is granted access.

Salting is a critical component of secure password storage and is widely used in modern cryptographic systems to protect sensitive information from unauthorized access.