Skip to content

Instantly share code, notes, and snippets.

@edamtoft
Last active March 21, 2019 18:14
Show Gist options
  • Save edamtoft/56f9ec95046e58964c653a5a9d4aec3a to your computer and use it in GitHub Desktop.
Save edamtoft/56f9ec95046e58964c653a5a9d4aec3a to your computer and use it in GitHub Desktop.
public string Hash(string password)
{
using (var algorithm = new Rfc2898DeriveBytes(
password,
SaltSize,
Options.Iterations,
HashAlgorithmName.SHA256))
{
var key = Convert.ToBase64String(algorithm.GetBytes(KeySize));
var salt = Convert.ToBase64String(algorithm.Salt);
return $"{Options.Iterations}.{salt}.{key}";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment