public void Version2EncoderTest() { // Arrange var seed = new byte[32]; // signingKey RandomNumberGenerator.Create().GetBytes(seed); var sk = Ed25519.ExpandedPrivateKeyFromSeed(seed); //var secret = Convert.ToBase64String(sk); //BitConverter.ToString(sk).Replace("-", string.Empty); // Hex Encoded // Act var encoder = new PasetoEncoder(cfg => cfg.Use <Version2>(sk)); // defaul is public purpose var token = encoder.Encode(new PasetoPayload { { "example", HelloPaseto }, { "exp", UnixEpoch.ToUnixTimeString(DateTime.UtcNow.AddHours(24)) } }); // Assert Assert.IsNotNull(token); }
/// <summary> /// Adds an issued claim to the Paseto. /// The Utc time will be converted to Unix time. /// </summary> /// <param name="time">The Utc time.</param> /// <returns>Current builder instance</returns> public static PasetoBuilder <TProtocol> IssuedAt <TProtocol>(this PasetoBuilder <TProtocol> builder, DateTime time) where TProtocol : IPasetoProtocol, new() => builder.AddClaim(RegisteredClaims.IssuedAt, UnixEpoch.ToUnixTimeString(time));