namespace slskd.Security
{
using Microsoft.AspNetCore.Cryptography.KeyDerivation;
using System.Security.Cryptography;
///
/// PBKDF2/RFC 2898 implementation
///
public static class PBKDF2
{
///
/// Gets a 256 bit (32 byte) key derived from the specified using PBKDF2/RFC 2898
///
///
///
public static byte[] GetKey(string password)
{
byte[] salt = new byte[16];
int iterations = 1000;
using (var rng = RandomNumberGenerator.Create())
{
rng.GetBytes(salt);
return KeyDerivation.Pbkdf2(password, salt, KeyDerivationPrf.HMACSHA256, iterations, 32);
}
}
}
}