# Can the salting function complexity improve the hash robustness?

I'm quite novice in security, and all examples I saw seem to salt the password by concatenating it, or by applying a simple binary OR or XOR. So the hash is based on "salt + password", "salt | password", etc.

If I'm right, a hacker should know how the password has been salted in order to retrieve a user password. So, can the complexity of the salting method improve the overall security?

• If you read salt and password are combined by XOR, move to other readings. If that's OR, run.
– fgrieu
Commented Oct 29, 2015 at 11:49
• A longer and more complex salt makes the hash less vulnerable to a rainbow table attack Commented Oct 31, 2015 at 2:23

First, good password hashing functions like PBKDF2 and scrypt usually take the password and salt as separate parameters, meaning the user does not have to worry about this. However, with some algorithms they do and in any case the theoretical question is important.

Some of those methods you mention are clearly worse than others:

• Binary OR would be particularly bad and I hope it is never used. Any position where the salt has a 1 bit would be 1 regardless of the password bit, so about half the entropy in the password would be lost. (AND would be the same, just with bits reversed.)
• XOR is not as bad, but two different salt-password pairs can lead to the same password hash. That makes a parallel attack on many users' passwords easier than it has to be.
• Some sort of addition (e.g. byte-wise) would have the same problem as XOR.

The normal method is to concatenate. It loses no entropy and produces a unique input into the hash function for every salt and password. There is really no advantage to doing anything more complex as the user, because that would effectively be just another part of the password hash.

• And I guess that concatenating twice (like as prefix and suffix) could be bad, as it generates a redundant pattern? Commented Oct 29, 2015 at 11:01
• @XavierPortebois, no it should not hurt, but neither should it help with a good password hash.
– otus
Commented Oct 29, 2015 at 11:18