Dosaic.Extensions.Sqids
1.1.3
dotnet add package Dosaic.Extensions.Sqids --version 1.1.3
NuGet\Install-Package Dosaic.Extensions.Sqids -Version 1.1.3
<PackageReference Include="Dosaic.Extensions.Sqids" Version="1.1.3" />
<PackageVersion Include="Dosaic.Extensions.Sqids" Version="1.1.3" />
<PackageReference Include="Dosaic.Extensions.Sqids" />
paket add Dosaic.Extensions.Sqids --version 1.1.3
#r "nuget: Dosaic.Extensions.Sqids, 1.1.3"
#addin nuget:?package=Dosaic.Extensions.Sqids&version=1.1.3
#tool nuget:?package=Dosaic.Extensions.Sqids&version=1.1.3
Dosaic.Extensions.Sqids
Dosaic.Extensions.Sqids is an extension library that provides methods to convert strings to and from Sqid format using the Sqids library.
Installation
To install the nuget package follow these steps:
dotnet add package Dosaic.Extensions.Sqids
or add as package reference to your .csproj
<PackageReference Include="Dosaic.Extensions.Sqids" Version="" />
Usage
The extension provides simple methods to convert strings to and from Sqid format.
Basic Conversion
Convert a string to a Sqid:
using Dosaic.Extensions.Sqids;
string originalString = "HelloWorld";
string sqidString = originalString.ToSqid();
Convert a Sqid back to the original string:
using Dosaic.Extensions.Sqids;
string sqidString = "kKs7PVdXUYnH"; // Example sqid
string originalString = sqidString.FromSqid();
Custom Encoder
You can also use a custom encoder for special use cases:
using Dosaic.Extensions.Sqids;
using Sqids;
var customEncoder = new SqidsEncoder<char>(new SqidsOptions
{
Alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",
MinLength = 8
});
string originalString = "HelloWorld";
string sqidString = originalString.ToSqid(customEncoder);
string decodedString = sqidString.FromSqid(customEncoder);
Default Configuration
By default, the extension uses the following configuration:
- Alphabet: "kKsW7PVdXUYnHgQ6rujl0GepfNzB2qZ9bC83IyDmOAtJ4hcSvM1Roaw5LxEiTF"
- Minimum Length: 10
You can modify the default encoder if needed:
using Dosaic.Extensions.Sqids;
using Sqids;
SqidExtensions.Encoder = new SqidsEncoder<char>(new SqidsOptions
{
Alphabet = "yourCustomAlphabet",
MinLength = 12
});
Use Cases
Sqids are useful for:
- Creating URL-friendly identifiers
- Obfuscating sequential IDs
- Generating short, unique string identifiers
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | 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 was computed. 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. |
-
net9.0
- Sqids (>= 3.1.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Dosaic.Extensions.Sqids:
Package | Downloads |
---|---|
Dosaic.Plugins.Persistence.S3
A plugin-first dotnet framework for rapidly building anything hosted in the web. |
|
Dosaic.Plugins.Persistence.VaultSharp
A plugin-first dotnet framework for rapidly building anything hosted in the web. |
GitHub repositories
This package is not used by any popular GitHub repositories.