Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is "salt" when relating to MYSQL sha1?

Tags:

mysql

sha1

salt

What is "salt" when relating to MYSQL sha1? I have no idea what salt is when relating to sha1 password encryptions? Can someone please explain what it is?

like image 675
Noah R Avatar asked Dec 04 '10 03:12

Noah R


People also ask

What are salted SHA1 password hashes?

The algorithms It should not be used to secure passwords. Secure Hash Algorithm 1 (SHA-1) is cryptographic hashing algorithm originally design by the US National Security Agency in 1993 and published in 1995. It generates 160-bit hash value that is typically rendered as a 40-digit hexadecimal number.

What is SHA1 in MySQL?

The MySQL SHA1() function is used for encrypting a string using the SHA-1 technique. The SHA1 stands for secure hash algorithm and it produces a 160-bit checksum for a user inputted string. The MySQL SHA1() function returns NULL if the string passed as an argument is a NULL string.

How many bits is a salted SHA1?

SHA-1: A 160-bit hash function which resembles the earlier MD5 algorithm. This was designed by the National Security Agency (NSA) to be part of the Digital Signature Algorithm. Cryptographic weaknesses were discovered in SHA-1, and the standard was no longer approved for most cryptographic uses after 2010.

What is a salt and why should a salt be used whenever passwords are hashed?

Hashing takes plaintext data elements and converts them into consistent ciphertext outputs used for data verification. Salting adds random characters to data, like passwords, to thwart hackers who look for consistent words and phrases in sensitive data in order to decode it.


1 Answers

A salt is a value that is added to a password (or other secret) which you want to hash one way. This means it could be before, after, or somewhere inside the password, as long as its position and value is consistent for a given supplied password.

What this does is it mitigates dictionary attacks - basically dictionaries of common passwords pre-hashed with no salt - from being used to "guess" a one way password as long as the attacker does not know the hash. If every password has a different hash then it makes it very difficult for an attacker to create a dictionary optimized for cracking your passwords (they would need a dictionary for each separate salt and they would also need to know where the salt was placed in each password).

Of course for all of this to be applicable an attacker must have the hashes of your passwords in the first place. This has nothing to do with attacking passwords by guessing them through some input prompt.

Regarding MySQL specifically if you provide a salt when hashing a password, make sure you record what that salt was somewhere. Then when a user attempts authentication you combine that recorded salt value with the password (during the call to crypt for example) and if the resulting hash matches then they have entered the correct password. (Note that at no time is the hashing of a password reversed; thus one way.)

like image 128
cfeduke Avatar answered Sep 19 '22 04:09

cfeduke