Skip to content

Instantly share code, notes, and snippets.

@JoeSz
Created July 1, 2017 10:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoeSz/65769ff30c650c136977c092982ed442 to your computer and use it in GitHub Desktop.
Save JoeSz/65769ff30c650c136977c092982ed442 to your computer and use it in GitHub Desktop.
public static byte[] GenerateRandomSalt()
{
//Source: http://www.dotnetperls.com/rngcryptoserviceprovider
byte[] data = new byte[32];
using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
{
// Ten iterations.
for (int i = 0; i < 10; i++)
{
// Fill buffer.
rng.GetBytes(data);
}
}
return data;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment