We recently had a great discussion about best practices for using a password, you could find great ideas there:
Salting Your Password: Best Practices?
I found that one of the simplest, although fairly safe, is to use a GUID as your salt. It is random and long enough. It works best if you enable GUID string formatting (the characters '{' and '-'), but you don't need this.
Remember that salt should be unique for each cell, and this is the most secure, you should use a cryptographically secure random number generator. Remember also that you must store the salt along with the password, otherwise you will not be able to check the plaintext version against the hash version! You can store salt that is not encrypted if you want; Usually I put it in a field in the same table as the password. The purpose of salt is not to remain hidden, it is to make complex rainbow tables (hopefully impossible) for timely calculation.
Here is a quick snippet that will work in C #:
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); byte[] buffer = new byte[1024]; rng.GetBytes(buffer); string salt = BitConverter.ToString(buffer); var saltedPassword = password + salt;
or...
var salt = Guid.NewGuid().ToString(); var saltedPassword = password + salt;
Randolpho
source share