Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between SALT and KEY. Encryption

Tags:

Alright, so im trying to learn a little about Encrypting messages in my java application. I just found out that SALT and KEY aren't the same.

Can someone help me understand what the difference between the two is?

like image 783
cody Avatar asked Sep 05 '11 01:09

cody


People also ask

What is the difference between encryption 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.

Is salt used for encryption?

In cryptography, a salt is random data that is used as an additional input to a one-way function that hashes data, a password or passphrase. Salts are used to safeguard passwords in storage.

What does salting mean in encryption?

Salting is a concept that typically pertains to password hashing. Essentially, it's a unique value that can be added to the end of the password to create a different hash value. This adds a layer of security to the hashing process, specifically against brute force attacks.

What does it mean to salt a password?

Password salting is a technique to protect passwords stored in databases by adding a string of 32 or more characters and then hashing them. Salting prevents hackers who breach an enterprise environment from reverse-engineering passwords and stealing them from the database.


2 Answers

The key is, crudely, the equivalent of a password; you use it to encrypt a message, and then the same key gets used to decrypt it back to the original plaintext. (Well, it gets a little more complex, once you have public and private keys, and so on.)

A salt is most typically encountered with cryptographic hash functions, not encryption functions. The idea is that rather than hashing just your data (e.g. a password), you hash data+salt, where salt is typically a randomly-generated string. They have (at least) two purposes:

  • To foil an attacker who has access to the hashed data from identifying a collision using a rainbow table.
  • To slow down an attacker who's trying a brute-force attack.
like image 106
Oliver Charlesworth Avatar answered Oct 06 '22 04:10

Oliver Charlesworth


The key is essentially the password with which you lock the original content.

To make the password more difficult to reverse engineer, you can add a salt to the produced encryption.


To give an obviously simple example, lets say you want to encrypt a character string. Your encryption routine is to reverse the word. So, for the string "Hello, World", after running encryption, your string would be "dlroW ,olleH". You could then add a salt to it. In this example, the salt will be "foo", so the result after salting would be "dlroW ,olleHfoo". Now, if someone managed to reverse engineer your encryption algorithm, they'd get "oofHello World", which is not the original message, and thus your information is still safe!

This really comes into use when you iteratively encrypt, eg,
result = salt + encrypt(salt+encrypt(salt+encrypt(message))).

like image 40
Jordaan Mylonas Avatar answered Oct 06 '22 05:10

Jordaan Mylonas