Branca 0.8.1
dotnet add package Branca --version 0.8.1
NuGet\Install-Package Branca -Version 0.8.1
<PackageReference Include="Branca" Version="0.8.1" />
<PackageVersion Include="Branca" Version="0.8.1" />
<PackageReference Include="Branca" />
paket add Branca --version 0.8.1
#r "nuget: Branca, 0.8.1"
#:package Branca@0.8.1
#addin nuget:?package=Branca&version=0.8.1
#tool nuget:?package=Branca&version=0.8.1
Branca
A .NET Standard 2.1 library for generating and validating Branca tokens.
Branca tokens are authenticated and encrypted API tokens using modern crypto. They use IETF XChaCha20-Poly1305 AEAD symmetric encryption to create encrypted and tamperproof tokens, base62 encoded to be URL safe. The payload is an arbitrary sequence of bytes: a JSON object, plain text or binary data serialized by MessagePack or Protocol Buffers.
Usage
Configure a BrancaService with a 32-byte secret key:
using Branca;
BrancaKey key = BrancaKey.Generate();
BrancaService branca = new(key);
Existing keys load from hexadecimal, Base64Url, Base62 or raw bytes:
BrancaKey key = BrancaKey.FromHex(
"73757065727365637265746b6579796f7573686f756c646e6f74636f6d6d6974");
Encode a payload into a token:
string token = branca.Encode("Hello, World!");
Decode and validate a token:
if (branca.TryDecode(token, out byte[] payload))
{
string message = Encoding.UTF8.GetString(payload);
}
Tokens are valid for an hour by default; configure BrancaSettings to change the token lifetime and other options. Older keys listed in PreviousKeys keep validating after a rotation, and ClockSkewInSeconds tolerates clock drift between issuers and validators. A single BrancaService instance is safe for concurrent use.
The library targets .NET Standard 2.1 and .NET 10, and is trimming and Native AOT compatible.
See the repository for detailed documentation and examples.
License
Branca is free software, licensed under the GNU Lesser General Public License v3.0 or later.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Branca:
| Package | Downloads |
|---|---|
|
Branca.AspNetCore
ASP.NET Core authentication handler for Branca tokens. |
GitHub repositories
This package is not used by any popular GitHub repositories.