public static string HashPassword(string username, string password) { var salt = Sha256(username); var derived = Pbkdf2.Generate(password, salt, 10000, 32); return("tk-v1-" + derived.ToHex()); }
public static byte[] DecryptMasterKey(string password, byte[] salt, byte[] encryptedKey) { var key = Pbkdf2.Generate(password, salt, 10000, 32); return(Decrypt(key, encryptedKey).ToUtf8().DecodeHex()); }