shortid 1.0.3
See the version list below for details.
dotnet add package shortid --version 1.0.3
NuGet\Install-Package shortid -Version 1.0.3
<PackageReference Include="shortid" Version="1.0.3" />
paket add shortid --version 1.0.3
#r "nuget: shortid, 1.0.3"
// Install shortid as a Cake Addin #addin nuget:?package=shortid&version=1.0.3 // Install shortid as a Cake Tool #tool nuget:?package=shortid&version=1.0.3
shortid
About ShortId
A csharp library to generate completely random short id's. they can be used as primary keys or unique identifiers. This library is different in that you can specify the length of the id's generated.
How to use
To make use of the shortid
, add it to your project via the Nuget package manager UI or console via this command:
Install-Package shortid
Add the following using command to the top of your csharp code file:
using shortid;
This gives your code access the classes and methods of the shortid
namespace.
To generate a unique id of any length between 7 and 14, you call the Generate
method without parameters.
string id = ShortId.Generate();
// id = KXTR_VzGVUoOY
If you want to include numbers in the generated id, then you call the Generate
method with a boolean indicating your preference.
string id = ShortId.Generate(true);
// id = O_bBY-YUkJg
If you do not want special characters i.e _ and - in your generated id, then call the Generate
method with two boolean parameters, the first indicating whether or not you want numbers and the second indicating whether or not you want special characeters.
string id = ShortId.Generate(true, false);
// id = waBfk3z
If you want to specify the length of the generated id, call the Generate
method with an integer parameter which is the desired length.
string id = ShortId.Generate(8);
// id = M-snXzBk
If you want to control the type of id generated by specifying whether you want numbers, special characters and the length, call the Generate
method and pass three parameters, the first a boolean stating whether you want numbers, the second a boolean stating whether you want special characters, the last a number indicating your length preference.
string id = ShortId.Generate(true, false, 12);
// id = VvoCDPazES_w
NOTE: when specifying the desired length, shorter lengths increase the possibility thata duplicate id would be generated
Customize ShortId
ShortId
has several features that help with customizing the ids generated. Characters sets can be introduced and the random number generator can be seeded.
To change the character set in use, run the following:
string characters = //whatever you want;
ShortId.SetCharacters(characters);
NOTE: the new character set must number null
, an empty string or whitespace. Also, all whitespace characters would be removed, finally the character set cannot be less than 20 characters.
ShortId
also allows the seed for the random number generator to be set.
To set the seed, run the following:
int seed = 1939048828;
ShortId.SetSeed(seed);
Finally, ShortId
allows for all customizations to be reset using the following:
ShortId.Reset();
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. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.3 is compatible. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 was computed. netstandard2.1 was computed. |
.NET Framework | net40 is compatible. net403 was computed. net45 is compatible. net451 was computed. net452 was computed. net46 was computed. 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 | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.0
- No dependencies.
-
.NETFramework 4.5
- No dependencies.
-
.NETStandard 1.3
- NETStandard.Library (>= 1.6.1)
NuGet packages (13)
Showing the top 5 NuGet packages that depend on shortid:
Package | Downloads |
---|---|
Dmaal.Core.Helper
Package Description |
|
kotori-core
Kotori core library. |
|
Programatica.Framework.Mvc
Development framework accelarator |
|
Yamf.Multitenancy
Package Description |
|
IdentityServer4.Contrib.RavenDB
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
4.0.0 | 1,816,219 | 4/21/2022 |
3.0.2 | 352 | 11/5/2023 |
3.0.1 | 945,890 | 4/11/2021 |
3.0.0 | 338,360 | 8/27/2020 |
2.0.4 | 41,151 | 8/26/2020 |
2.0.3 | 64,579 | 7/4/2020 |
2.0.2 | 7,269 | 6/29/2020 |
2.0.1 | 152,818 | 3/26/2020 |
2.0.0 | 482,318 | 3/9/2018 |
1.0.4 | 5,097 | 2/6/2018 |
1.0.3 | 10,058 | 11/27/2017 |
1.0.2 | 6,296 | 7/5/2017 |
1.0.1 | 1,136 | 6/13/2017 |
1.0.0 | 1,816 | 6/10/2017 |
Move the library to NET Standard