UUIDv47Sharp 0.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package UUIDv47Sharp --version 0.1.0
                    
NuGet\Install-Package UUIDv47Sharp -Version 0.1.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="UUIDv47Sharp" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="UUIDv47Sharp" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="UUIDv47Sharp" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add UUIDv47Sharp --version 0.1.0
                    
#r "nuget: UUIDv47Sharp, 0.1.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.
#:package UUIDv47Sharp@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=UUIDv47Sharp&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=UUIDv47Sharp&version=0.1.0
                    
Install as a Cake Tool

UUIDv47Sharp

This is a port of stateless-me/uuidv47 to the C#/.NET ecosystem. With this library, you can store UUIDv7s in a database in time-ordered sequence while simultaneously exposing UUIDs in a format similar to UUIDv4 to external APIs.

English Japanese

What's this?

This provides a deterministic and reversible conversion method between UUID formats like UUIDv7 and UUIDv4. This is achieved by XOR-masking only the timestamp portion of UUIDv7 using a reversible encrypted ShiHash-4-4 stream that is tied to the UUID's own random bits.

Usage

using UUIDv47Sharp;

var key = new Key(0x0123456789abcdef, 0xfedcba9876543210);
// Or generate a random key:
// var key = Key.NewRandom();

// Parse a UUIDv7
// (e.g., from your database)
var v7 = Uuid.Parse("018f2d9f-9a2a-7def-8c3f-7b1a2c4d5e6f");

// Encode to facade (v4-like) for external use
var facade = Uuid47Codec.Encode(v7, key);
Console.WriteLine($"ExternalID: {facade}");
// Output: External ID: 2463c780-7fca-4def-8c3f-7b1a2c4d5e6f

// Decode back to original v7 for internal use
var decoded = Uuid47Codec.Decode(facade, key);
Console.WriteLine($"InternalID: {decoded}");
// Output: Internal ID: 018f2d9f-9a2a-7def-8c3f-7b1a2c4d5e6f

Security Tips

  • Carefully safeguard the key used for modification. This key will be used when reversing the conversion to UUIDv7.
  • The generated UUIDv4-like output only encrypts the timestamp portion; the random bits remain unprotected.
  • For UUIDv7 generation, use a sufficiently secure algorithm and library.

Security

If you discover any security vulnerabilities in this software, please DO NOT create an issue or pull request. Instead, please report it using one of the following methods:

  • Submit a report to our Security Advisory page on GitHub
  • Contact us directly at taiseiue@wsnet.jp (you can obtain our PGP key from OpenPGP)

If an issue related to a security vulnerability is created, we will accept the report but subsequently delete the associated issue.

Credits

This is a C# implementation of the highly efficient UUID generation library stateless-me/uuidv47 developed by Stateless Limited. We also referenced the Go language implementation n2p5/uuid47 of uuidv47 for implementation guidance.

License

This software is released under the The MIT License.

Copyright (c) 2025 Taisei Uemura
Released under the MIT license

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on UUIDv47Sharp:

Package Downloads
MaskedUUID.AspNetCore

ASP.NET Core で UUIDv7 のタイムスタンプ部を UUIDv47 アルゴリズムでマスクし、可逆的に変換するライブラリ

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.1 309 9/22/2025
0.1.0 235 9/21/2025