public new Podcast AddOrUpdate(Podcast podcast) { // hash the passwords if (podcast.AuthPassword == null || podcast.AuthPassword.Length == 0 || (!podcast.Private)) { return(base.Update(podcast)); } var salt = PBKDFGenerators.GenerateSalt(); var password = PBKDFGenerators.GenerateHash(podcast.AuthPassword, salt); podcast.AuthPasswordSalt = salt; podcast.AuthPassword = password; return(base.Update(podcast)); }
// Make your own implementation of this public bool IsAuthorized(Podcast podcast, string username, string password) { var record = _podcastRepository .GetAll() .SingleOrDefault(r => r.AuthUserName.Equals(username)); if (record is null) { return(false); } var pwd = Encoding.ASCII.GetBytes(password); var checkHash = PBKDFGenerators.GenerateHash(pwd, podcast.AuthPasswordSalt); return(podcast.AuthPassword.SequenceEqual(checkHash)); }