SchrottID 3.1.0
dotnet add package SchrottID --version 3.1.0
NuGet\Install-Package SchrottID -Version 3.1.0
<PackageReference Include="SchrottID" Version="3.1.0" />
<PackageVersion Include="SchrottID" Version="3.1.0" />
<PackageReference Include="SchrottID" />
paket add SchrottID --version 3.1.0
#r "nuget: SchrottID, 3.1.0"
#:package SchrottID@3.1.0
#addin nuget:?package=SchrottID&version=3.1.0
#tool nuget:?package=SchrottID&version=3.1.0
SchrottID
<img alt="Nuget" src="https://img.shields.io/nuget/dt/SchrottID?logo=nuget&label=NuGet&link=https%3A%2F%2Fwww.nuget.org%2Fpackages%2FSchrottID%2F">
SchrottID is a library for generating short, non-consecutive and opaque IDs from unsigned integers. These can be used to obfuscate integer primary keys from your database and prevent enumeration of rows and leaking other confidential information (see German tank problem).
SchrottIDs can be used where UUIDs would be impractical and too long to remember.
// Choose a character set for your SchrottIDs
string alphabet = Alphabets.Base64;
// Generate a permutation for your alphabet
// The permutation is your "key" for encoding and decoding
// You cannot decode IDs correctly without this key
string permutation = SchrottIdUtil.GeneratePermutation(alphabet);
// Choose a minimum length for your SchrottIDs
int minimumLength = 3;
// Make sure to store the three parameters above
// Create a encoder/decoder
SchrottIdEncoder schrottId = new SchrottIdEncoder(alphabet, permutation, minimumLength);
// A primary key from your database
ulong primaryKey = 420;
// Encode primaryKey to a SchrottID that you can safely expose
string externalId = schrottId.Encode(primaryKey);
// externalId = 9TN
// Decode back into your internal ID
ulong decodedKey = schrottId.Decode(externalId);
// decodedKey = 420
Implementations in other languages should very similar APIs. IDs generated by the same major version of the library are always stable.
Creating a new implementation
Implementations in other languages are very welcome. Create a new folder for your implementation and submit a pull
request. Use test/control.txt to verify your implementation. C# is the reference implementation.
This library is inspired by block-id and removes the dependency on a deterministic random number generator so implementations in other languages are easier. The libraries are not cross-compatible.
Disclaimer: I'm not a cryptographer and IDs generated by this library can possibly be reversed engineered. Use with caution.
| 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 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.