![]() |
VOOZH | about |
dotnet add package Nanoid --version 3.1.0
NuGet\Install-Package Nanoid -Version 3.1.0
<PackageReference Include="Nanoid" Version="3.1.0" />
<PackageVersion Include="Nanoid" Version="3.1.0" />Directory.Packages.props
<PackageReference Include="Nanoid" />Project file
paket add Nanoid --version 3.1.0
#r "nuget: Nanoid, 3.1.0"
#:package Nanoid@3.1.0
#addin nuget:?package=Nanoid&version=3.1.0Install as a Cake Addin
#tool nuget:?package=Nanoid&version=3.1.0Install as a Cake Tool
👁 Build Status
👁 Build status
👁 NuGet Badge
This package is .NET implementation of ai's nanoid!
Safe. It uses thread safe cryptographically strong random generator by default.
Compact. It uses more symbols than UUID (A-Za-z0-9_-)
and has the same number of unique options in just 22 symbols instead of 36.
Fast. Nanoid is as fast as UUID but can be used in URLs.
Install with nuget:
PM> Install-Package Nanoid
The default method uses URL-friendly symbols (A-Za-z0-9_-) and returns an ID
with 21 characters (to have a collision probability similar to UUID v4).
var id = Nanoid.Generate(); //=> "Uakgb_J5m9g-0JDMbcJqLJ"
Symbols -,.() are not encoded in the URL. If used at the end of a link
they could be identified as a punctuation symbol.
If you want to reduce ID length (and increase collisions probability), you can pass the size as an argument:
var id = Nanoid.Generate(size: 10); //=> "IRFa-VaY2b"
If you want to change the ID's alphabet or length you can pass alphabet and size.
var id1 = Nanoid.Generate(Nanoid.Alphabets.LowercaseLettersAndDigits, 10); //=> "4f90d13a42"
var id2 = Nanoid.Generate("1234567890abcdef", 5); //=> "2x501"
You can find a variety of useful alphabets typically used for
Nanoid generation in Nanoid.Alphabets.
To reason about the collision probabilities of a particular alphabet and id length combination, use the nanoid collision calculator.
By default, we use an internal global ThreadStatic
wrapper over System.Security.Cryptography.RandomNumberGenerator to generate Nanoids in a cryptographically secure
manner.
The ThreadStatic attribute ensures that you can safely generate ids across threads without having
to pass in your own Random object, by creating a separate instance of our random number generator per thread.
This method also avoids the need for any locks which ensures the id generation is fast as advertised.
You can replace the default safe random generator using the System.Random class.
For instance, to use a seed-based generator you can do this:
var random = Random(10);
var id = Nanoid.Generate(random, Nanoid.Alphabets.Letters, 10) //=> "fbAeFaaDeb"
If you want to use your own global random number generator, make sure you are aware of the thread safety implications.
Also note that the global random number generator is lazily initialized on first usage.
If you need to preload it you can call the Nanoid.GlobalRandom getter to force the
initialization to happen at that moment on the current thread.
The MIT License (MIT). Please see for more information.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 is compatible. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Nanoid:
| Package | Downloads |
|---|---|
|
BotSharp.Core
Open source LLM application framework to build scalable, flexible and robust AI system. |
|
|
Util.IdGenerator
Util.IdGenerator是Util应用框架的Id生成器封装类库 |
|
|
Lingman.Utils
Api Log的exception记录 |
|
|
Newguys.Utils
Package Description |
|
|
Meow.Core
Meow.Core 是 Meow 基础类库。 个人学习使用。 来源 作者:何镇汐 地址:https://github.com/dotnetcore/Util 请使用原作者版本,尊重原作者劳动成果,谢谢! |
Showing the top 6 popular GitHub repositories that depend on Nanoid:
| Repository | Stars |
|---|---|
|
dotnetcore/Util
Util是一个.Net平台下的应用框架,旨在提升中小团队的开发能力,由工具类、分层架构基类、Ui组件,配套代码生成模板,权限等组成。
|
|
|
SciSharp/BotSharp
AI Multi-Agent Framework in .NET
|
|
|
streetwriters/notesnook-sync-server
Sync server for Notesnook (self-hosting in alpha)
|
|
|
legend2ks/YoutubeDownloader
YouTube video/playlist/channel downloader
|
|
|
formcms/formcms
AI Agent: Open-source headless CMS built with ASP.NET Core (C#) and React, featuring REST APIs, GraphQL, and a GrapesJS page designer.
|
|
|
nnecrkvenuOX/formcms
AI Agent: Open-source headless CMS built with ASP.NET Core (C#) and React, featuring REST APIs, GraphQL, and a GrapesJS page designer.
|
3.1.0
- Various improvements and fixes. by @SasLuca, @Petteroe
- Target .NET Framework 4.8 and .NET 8.netstandard2.x no longer being available. by @oddeirik