BTSID 1.0.1

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

// Install BTSID as a Cake Tool
#tool nuget:?package=BTSID&version=1.0.1                

BTSID

BTSID is a .NET library that generates unique and short Base36 encoded IDs. This library is useful for creating short IDs for databases, URLs, and other applications where a compact identifier is needed.

Features

  • Convert integers, long, and DateTime to Base36 encoded strings
  • Generate unique Base36 encoded IDs based on different modes
  • Convert Base36 encoded strings back to decimal
  • Get the next Base36 encoded number in sequence

Installation

Install the package via NuGet Package Manager:

dotnet add package BTSID

Usage

Convert Numbers to Base36

using BTSID;

string base36 = 12345.ToBase36(); // "9ix"
string dateBase36 = DateTime.Now.ToBase36(); // Based on current DateTime

Generate Unique Base36 IDs

using BTSID;

string uniqueId = BTSID.NewBase36Number(NumberMode.Uniq);
string shortId = BTSID.NewBase36Number(NumberMode.Short);
string compressedId = BTSID.NewBase36Number(NumberMode.Compressed);

Convert Base36 to Decimal

using BTSID;

decimal decimalValue = BTSID.ToDecimal("9ix"); // 12345

Get Next Base36 Number

using BTSID;

string nextNumber = BTSID.GetNextNumber("9ix"); // "9iy"

Documentation

Methods

  • ToBase36(this string number): Converts a string representation of a number to Base36.
  • ToBase36(this long number): Converts a long number to Base36.
  • ToBase36(this int number): Converts an integer to Base36.
  • ToBase36(this DateTime dateTime): Converts a DateTime to Base36.
  • NewBase36Number(NumberMode mode): Generates a new Base36 number based on the specified mode.
  • GetNextNumber(string currentNumber): Gets the next Base36 number in sequence.
  • ToDecimal(string base36Number): Converts a Base36 number to decimal.

Enum

  • NumberMode
    • Uniq: Generates a unique Base36 number based on DateTime and process ID.
    • Short: Generates a Base36 number based on DateTime with milliseconds.
    • Compressed: Generates a Base36 number based on DateTime without milliseconds.

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.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
1.0.1 87 8/6/2024
1.0.0 76 8/6/2024