Skip to content

Instantly share code, notes, and snippets.

@shawnmclean
Created April 10, 2012 06:30
Show Gist options
  • Save shawnmclean/2348809 to your computer and use it in GitHub Desktop.
Save shawnmclean/2348809 to your computer and use it in GitHub Desktop.
SimpleCrypto.Net Basic PBKDF2 Hashing with salt settings
private ICryptoService cryptoService = new PBKDF2();
private const int SALT_SIZE = 16;
private const int HASH_ITERATIONS = 50;
private void SetNewPassword(User user, string newPassword)
{
//a new password hash is generated from a generated salt with the passed settings
user.Password = user.Password = cryptoService.Compute(newPassword, SALT_SIZE, HASH_ITERATIONS);
//assigning the generated salt to the user
user.PasswordSalt = cryptoService.Salt;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment