src/Foundation/Security/Gimela.Security/RandomGenerator.cs
/// <summary>
/// Generates a random salt value by giving a length.
/// </summary>
/// <param name="length">a value must be greater than 0</param>
/// <returns>The byte array of value that represents salt. This value is non-zero byte value.</returns>
/// <remarks>In cryptography, a salt consists of random bits, creating one of the inputs to a one-way function.</remarks>
Generates a random salt value by giving a length.
Generates a random salt value by giving a length .
public static byte[] NextRandomSalt(int length)
    {
      if (length <= 0)
      {
        throw new ArgumentOutOfRangeException("length", "Salt length must be greater than 0");
      }
      byte[] salt = new byte[length];
      using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
      {
        rng.GetNonZeroBytes(salt);
      }
      return salt;
    }
public static byte [ ] NextRandomSalt ( int length ) { if ( length <= 0 ) { throw new ArgumentOutOfRangeException ( " " , " " ) ; } byte [ ] salt = new byte [ length ] ; using ( RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider ( ) ) { rng . GetNonZeroBytes ( salt ) ; } return salt ; }
Generates a random salt value by giving a length.
Generates a random salt value by giving a length .
The byte array of value that represents salt. This value is non-zero byte value.
The byte array of value that represents salt . This value is non - zero byte value .
length
int
a value must be greater than 0
a value must be greater than 0
remarks
In cryptography, a salt consists of random bits, creating one of the inputs to a one-way function.
In cryptography a salt consists of random bits creating one of the inputs to a one - way function .