SourceExpress.ShorterGuid 2.0.0

dotnet add package SourceExpress.ShorterGuid --version 2.0.0
NuGet\Install-Package SourceExpress.ShorterGuid -Version 2.0.0
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="SourceExpress.ShorterGuid" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SourceExpress.ShorterGuid --version 2.0.0
#r "nuget: SourceExpress.ShorterGuid, 2.0.0"
#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 SourceExpress.ShorterGuid as a Cake Addin
#addin nuget:?package=SourceExpress.ShorterGuid&version=2.0.0

// Install SourceExpress.ShorterGuid as a Cake Tool
#tool nuget:?package=SourceExpress.ShorterGuid&version=2.0.0

SourceExpress.ShorterGuid

This library contains extension methods to generate a 26-character long string from the Guid, which is URL-safe and case-insensitive! It uses Base32 encoding with the following character set: ABCDEFGHIJKLMNOPQRSTUVWXYZ234567.

Inspired by CSharpVitamins.ShortGuid library which uses Base64 encoding and produces a 22-character long string, however it is case-sensitive!

Available on NuGet. To install, run the following command in the Package Manager Console:

PM> Install-Package SourceExpress.ShorterGuid

The Gist

It takes a standard guid like this:

7ff2d2cb-1e1d-41cc-b478-32adb96082bd

and shortens it to a smaller string like this:

ZPJPE7Y5D3GEDNDYGKW3SYECXU or zpjpe7y5d3gedndygkw3syecxu


Using the ShorterGuid

The ShorterGuid provides two extension methods for Guid class:

var guid = Guid.NewGuid();  // 7ff2d2cb-1e1d-41cc-b478-32adb96082bd
var shorterGuid = guid.ToShorterString(); // ZPJPE7Y5D3GEDNDYGKW3SYECXU
var guid = Guid.NewGuid();  // 7ff2d2cb-1e1d-41cc-b478-32adb96082bd
var shorterGuid = guid.ToLowerShorterString(); // zpjpe7y5d3gedndygkw3syecxu

If you need to get Guid from the ShorterGuid string, you can do that using second extension method:

var shorterGuid = "ZPJPE7Y5D3GEDNDYGKW3SYECXU"; // or "zpjpe7y5d3gedndygkw3syecxu"
var guid = shorterGuid.FromShorterString(); // 7ff2d2cb-1e1d-41cc-b478-32adb96082bd

Methods contain some internal error handling like wrong character or incorrect length of the ShorterGuid. See test project for more details.

Product Compatible and additional computed target framework versions.
.NET 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 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net6.0

    • No dependencies.
  • net7.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.

Version Downloads Last updated
2.0.0 2,635 11/9/2022
1.0.1 448 11/6/2022
1.0.0 433 11/6/2022

- 2.0.0 Migrated to RFC 4648 Base32 encoding
- 1.0.1 Fixed nuget configuration
- 1.0.0 Initial release.