How should I store data into my Mysql database, what type should I assign to a column storing salt values?

Software & CodingApps/ApplicationsComputer NetworkGeneral Topics

Salt is used to store your data securely. If we have to store user password securely, we need to use salt.

$pwd=hash(hash($password) + salt)

then store $pwd in your system instead of the real password.

So, the question is, how to define the salt value. Here is how:

// if (saltBytes == null)
   // Define min and max salt sizes.
   int minSaltSize = 4;
   int maxSaltSize = 8;

   // Generate a random number for the size of the salt.
   Random random = new Random();
   int saltSize = random.Next(minSaltSize, maxSaltSize);

   // Allocate a byte array, which will hold the salt.
   saltBytes = new byte[saltSize];

   // Initialize a random number generator.
   RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();

   // Fill the salt with cryptographically strong byte values.
Published on 14-Dec-2018 16:37:01