PrettyId 1.0.3

dotnet add package PrettyId --version 1.0.3                
NuGet\Install-Package PrettyId -Version 1.0.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PrettyId" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PrettyId --version 1.0.3                
#r "nuget: PrettyId, 1.0.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PrettyId as a Cake Addin
#addin nuget:?package=PrettyId&version=1.0.3

// Install PrettyId as a Cake Tool
#tool nuget:?package=PrettyId&version=1.0.3                

alt tag

PrettyId

NuGet Version NuGet

PrettyId is a simple library for creating uniform IDs similar to those used by Stripe.

Under the hood, PrettyId uses base64 strings of GUIDs to generate a random identifier of the specified length. You can choose to set a prefix that can be included in the result.

New in v1.0.x

  • Initial release
  • Added support for generating valid base64 values

Help or feedback

First things first - do you need help or have feedback? File an issue here!

Performance and Security

It's pretty quick 😃 The shorter the list of allowed characters, the slower it will run.

On security, the library has no way to guarantee that it will never issue the same ID twice. It is however based on GUIDs, which have a ridiculously low theoretical probability of collision (I would encourage you to check out Stephen Cleary's blog post at https://blog.stephencleary.com/2010/11/few-words-on-guids.html)

Simple Example

using PrettyId;

Console.WriteLine(IdGenerator.Generate());
// 32 bytes in length by default
// 5wS4rcgWk6Tr0CO0sfXgA0NAtlOp60C

Console.WriteLine(IdGenerator.Generate("data_", 32));
// 32 bytes in length, including the header
// data_0mAg6shuO0GSplEn7GmXR

Console.WriteLine(IdGenerator.Generate(64));
// 64 bytes in length
// KL5ULxfC2kujhcMtDKnDKgUAANsBAdESqJBDKIgvLwdxfjo03uJEKLkn9csMt4Q

Console.WriteLine(IdGenerator.GenerateBase64("b64_", 64));
// 64 bytes in length, including the header
// b64_TE42UVVmRmltVUtXMExOdStGSE9Pdz09bDlvR1dBSHErVXl4VG1mRndSYWhH

Want to set the list of valid characters?

IdGenerator.ValidCharacters = new char[] { 'a', 'b', 'c', 'd', ... };

Or use one of the built-in character sets.

IdGenerator.ValidCharacters = DefaultCharacterSets.EnglishAlphanumeric;
IdGenerator.ValidCharacters = DefaultCharacterSets.Base64;
IdGenerator.ValidCharacters = DefaultCharacterSets.USKeyboard;

Have a recommendation for default character sets? Please file an issue with the details or submit a PR!

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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 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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
.NET Framework net461 is compatible.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.6.1

    • No dependencies.
  • .NETFramework 4.6.2

    • No dependencies.
  • .NETFramework 4.8

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on PrettyId:

Package Downloads
S3Server

Emulated Amazon Web Services (AWS) Simple Storage Service (S3) server-side interface.

S3Lite

Lightweight Amazon S3 client without all the heft and dependency drag of the official library.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 44 12/24/2024
1.0.2 3,584 3/20/2024
1.0.1 6,922 8/31/2023
1.0.0.4 1,035 8/19/2023
1.0.0.3 7,916 11/19/2021
1.0.0.2 523 11/18/2021
1.0.0.1 503 11/12/2021
1.0.0 7,372 4/16/2021

Add generation of valid base64 values.