Пример #1
0
        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);
        }
Пример #2
0
 private string GenerateToken(bool authenticated)
 {
     return(encoder.Encode(new PasetoPayload {
         { IsAuthenticated, authenticated }
     }));
 }