Sqiddler 0.0.4
dotnet add package Sqiddler --version 0.0.4
NuGet\Install-Package Sqiddler -Version 0.0.4
<PackageReference Include="Sqiddler" Version="0.0.4" />
<PackageVersion Include="Sqiddler" Version="0.0.4" />
<PackageReference Include="Sqiddler" />
paket add Sqiddler --version 0.0.4
#r "nuget: Sqiddler, 0.0.4"
#:package Sqiddler@0.0.4
#addin nuget:?package=Sqiddler&version=0.0.4
#tool nuget:?package=Sqiddler&version=0.0.4
Sqiddler
Sqiddler applies Sqids to serialize integer ids to obfuscated strings. It uses ASP.NET Core's built-in JSON serialization and model binding features to automatically convert between integers and Sqid-strings. It also shuffles the alphabet by entity to make it harder to mix ids.
Getting Started
Install NuGet package Sqiddler
dotnet add package Sqiddler
Annotate your id properties with [JsonSqid<TEntity>] and id route parameters with SqidParam<TEntity> to serialize them to Sqid-strings.
public class Person
{
public int Id { get; set; }
}
public class PersonDto
{
// Id gets serialized to Sqid-string
[JsonSqid<Person>]
public int Id { get; set; }
public string OtherProperty { get; set; }
}
public class PersonEndpoints
{
public void Map(WebApplication app)
{
app.MapGet("person/{id}", GetPerson);
}
public static async Task<Ok<MyDto>> GetPerson(ISender sender, SqidParam<Person> id)
{
return Task.FromResult(new PersonDto()
{
Id = 42,
OtherProperty = "Hello, World!"
}
}
}
Configuration
Configure Sqids in Program.cs
var builder = WebApplication.CreateBuilder(args);
// configure SqidsOptions from appsettings.json
builder.Configuration.GetSection("Sqids").Bind(SqidsOptionsFactory.Default);
// optimize SqidsOptions.MinLength for TEntity
SqidsOptionsFactory.Configure<Person>(4); // enough for 100_000
var app = builder.Build();
app.Run();
Configure Sqids.SqidsOptions in appsettings.json
"Sqids": {
// generated from https://sqids.org/playground
"Alphabet": "kBZDsjNeIWrQUSqExvwgdcnyl05X2F7f3pYVO9MaRhtLoP8GbiuzCm1T6KAJH4"
}
Open API
Install NuGet package Sqiddler.OpenApi instead of Sqiddler
dotnet add package Sqiddler.OpenApi
Register Open API in Program.cs
var builder = WebApplication.CreateBuilder(args);
services.AddOpenApi(options =>
{
// reflect Sqid-string changes in Open API
options.AddSqids(options);
});
var app = builder.Build();
app.MapOpenApi();
app.Run();
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. 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 is compatible. 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. |
-
net10.0
- Sqiddler.Core (>= 0.0.4)
- Sqids (>= 3.1.0)
-
net8.0
- Sqiddler.Core (>= 0.0.4)
- Sqids (>= 3.1.0)
-
net9.0
- Sqiddler.Core (>= 0.0.4)
- Sqids (>= 3.1.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Sqiddler:
| Package | Downloads |
|---|---|
|
Sqiddler.OpenApi
Use Sqids in ASP.NET Core with Attributes |
|
|
Sqiddler.NSwag
Use Sqids in ASP.NET Core with Attributes |
GitHub repositories
This package is not used by any popular GitHub repositories.