JWTHelpers 1.0.1
dotnet add package JWTHelpers --version 1.0.1
NuGet\Install-Package JWTHelpers -Version 1.0.1
<PackageReference Include="JWTHelpers" Version="1.0.1" />
paket add JWTHelpers --version 1.0.1
#r "nuget: JWTHelpers, 1.0.1"
// Install JWTHelpers as a Cake Addin #addin nuget:?package=JWTHelpers&version=1.0.1 // Install JWTHelpers as a Cake Tool #tool nuget:?package=JWTHelpers&version=1.0.1
JWT Helpers
A helper library for using JWT with RSA public/private key encryption.
Getting Started
Install the nuget package in your project. When invoking the JWTHelper library you will pass a unique application name used in generating the tokens as the Issuer (iss) property. If you already have an RSA public and private keyset you can pass those in the PEM format when instantiating the helper library. If you only pass the ApplicationName parameter, then a new set of keys will be generated for you and you can read them in the .PublicKey and .PrivateKey properties.
You can also use the static library RSAHelper to generate a new set of public and private keys yourself.
Code Example
// How to use the RSAHelper static library to generate RSA public and private keys.
// The returned object will contain a new public and private key. If no bit length
// is passed to the GenerateNewRsaKey method the default is 1024. This value has to
// be a valid bit length (eg: 1024, 2048, 4096, etc.)
var key = RSAHelper.GenerateNewRsaKey(1024);
// Create an instance of the JWT Helper library
var jwt = new JWTHelper(string ApplicationName, string PublicKey, string PrivateKey);
// Create your payload to store values in your token.
Dictionary<string, object> payload = new Dictionary<string, object>();
payload.Add("FirstName", "John");
payload.Add("LastName", "Doe");
payload.Add("EmailAddress", "john.doe@domain");
var token = jwt.Encode(payload);
// To decode the token, just call the .Decode method.
var decoded = jwt.Decode(result.Token);
// If you only need to encode a single value you can call the EncodeSingleValue method.
var tokenFromSingleItem = jwt.EncodeSingleValue("UserId", 12345);
Contact
For support and information contact Brad Wickett at brad@wickett.net.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- JWT (>= 10.0.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on JWTHelpers:
Package | Downloads |
---|---|
HelpDesk.Client
A client for interacting with the EIT help desk. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.1 | 927 | 6/21/2023 |