public void ShouldConvertDateTimeToUnixTimestamp() { var psk = new Psk { Hash = "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff" }; psk.IsEqualTo("ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff").Should().BeTrue(); }
public bool IsAuthorized(AuthorizationFilterContext context, Psk psk) { using (var algorithm = psk.Algorithm) { var hash = algorithm.ComputeHash(Encoding.Default.GetBytes(_options.Secret + _options.Salt)); algorithm.Clear(); return(psk.IsEqualTo(Convert.ToBase64String(hash))); } }
public void ShouldConvertDateTimeToUnixTimestamp() { var psk = new Psk { Algorithm = SHA512.Create(), Hash = "ee26b0dd4af7e749aa1a8ee3c10ae9923f618980772e473f8819a5d4940e0db27ac185f8a0e1d5f84f88bc887fd67b143732c304cc5fa9ad8e6f57f50028a8ff", Timestamp = DateTime.UtcNow.ToUnix() }; psk.Timestamp.Should().Be(DateTime.UtcNow.ToUnix()); }
public static bool IsEqualTo(this Psk psk, string hash) { return(psk.Hash == hash); }