Paseto.NET, a Paseto (Platform-Agnostic Security Tokens) implementation for .NET
var token = new PasetoBuilder<Version2>()
.WithKey(secret)
.AddClaim("example", "Hello Paseto!")
.Expiration(DateTime.UtcNow.AddHours(24))
.AsPublic() // Purpose
.Build();
var encoder = new PasetoEncoder(cfg => cfg.Use<Version2>(sk)); // default is public purpose
var token = encoder.Encode(new PasetoPayload
{
{ "example", "Hello Paseto!" },
{ "exp", UnixEpoch.ToUnixTime(DateTime.UtcNow.AddHours(24)) }
});
v2.public.eyJleGFtcGxlIjoiSGVsbG8gUGFzZXRvISIsImV4cCI6IjE1MjEyNDU0NTAifQ2jznA4Tl8r2PM8xu0FIJhyWkm4SiwvCxavTSFt7bo7JtnsFdWgXBOgbYybi5-NAkmpm94uwJCRjCApOXBSIgs
var payload = new PasetoBuilder<Version2>()
.WithKey(publicKey)
.AsPublic() // Purpose
.AndVerifySignature()
.Decode(token);
var decoder = new PasetoDecoder(cfg => cfg.Use<Version2>(publicKey)); // default is public purpose
var payload = decoder.Decode(token);
{
"example": "Hello Paseto!",
"exp": "1521245450"
}
- Add support for local authentication for v1 and v2.
- Implement XChaCha20-Poly1305 algorithm
or use an external library
- Implement XChaCha20-Poly1305 algorithm
- Improve protocol versioning
- Add more documentation on the usage
- Extend the fluent builder API
- Add more tests
- Uses Ed25519 algorithm from CodesInChaos Chaos.NaCl cryptography library.
At its current state, libsodium-core and NSec does't support XChaCha20-Poly1305.