<p>How is the salt generated in HashProvider in Microsoft Enterprise Library when we set SaltEnabled?</p>

<p>Is it random to new machines? Is it some magic number?</p>

<p>(I know what is a salt, the question is what's the actual value of a/the salt in Enterprise Library HashProvider)</p>

Edit:
See Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.HashAlgorithmProvider for an example implementation. Hashing steps are:
If SaltEnabled, generate random bytes for the salt length using RNGCryptoServiceProvider.
Append the salt to the plaintext.
Hash the salted plaintext.
Then (this is the important step), append the salt again to the
hash
.
To compare against hashed text, you must use:
```
```
public bool CompareHash(byte[] plaintext, byte[] hashedtext)
```
```
versus rehashing and comparing. If you rehash, a new random salt is generated and you're lost.
CompareHash does the following:
Pulls the non-hashed salt off the hashtext. Remember, it was appended at step 4 above.
Uses that salt to compute a hash for the plaintext.
Compares the new hash with the hashedtext minus salt. If they're the same - true, else false.
Original:
"if salt is enabled on a HashProvider, the provider will generate a random sequence of bytes, that will be added to the hash. If you compare a hashed value with a unhashed value, the salt will be extracted from the hashed value and used to hash the unhashed value, prior to comparison."
and
"As for decoding as hash-value. this cannot be done. after creating a hash there should be no way to reverse this into the original value.
However, what you can do is compare an unhashed-value with a hashed-value by putting it through the same algorithm and comparing the output."
From
http://www.codeplex.com/entlib/Thread/View.aspx?ThreadId=10284