NetCid 1.2.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package NetCid --version 1.2.1
                    
NuGet\Install-Package NetCid -Version 1.2.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="NetCid" Version="1.2.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="NetCid" Version="1.2.1" />
                    
Directory.Packages.props
<PackageReference Include="NetCid" />
                    
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 NetCid --version 1.2.1
                    
#r "nuget: NetCid, 1.2.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.
#:package NetCid@1.2.1
                    
#: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=NetCid&version=1.2.1
                    
Install as a Cake Addin
#tool nuget:?package=NetCid&version=1.2.1
                    
Install as a Cake Tool

NetCid

NetCid is a C# (net10.0) implementation of the multiformats CID specification.

Features

  • CIDv0 and CIDv1 parsing, encoding, and round-tripping
  • CID conversion (ToV0, ToV1)
  • Binary CID decode/encode
  • Unsigned varint codec (multiformats-compatible, max 9-byte encoding)
  • Multihash model + SHA-256 / SHA-512 hash helpers
  • Multibase support for:
    • base58btc (z)
    • base32 lower/upper (b / B)
    • base36 lower/upper (k / K)
    • base64url (u)
  • Multicodec constants for common CID codecs (raw, dag-pb, dag-cbor, etc.)
  • Multicodec key-type constants (ed25519-pub, p256-pub, secp256k1-pub, etc.)
  • Multicodec prefix/decode API for varint-tagged byte buffers

Install

dotnet add package NetCid

Quick Start

using NetCid;
using System.Text;

// Parse existing CIDs
var v0 = Cid.Parse("QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n");
var v1 = Cid.Parse("bafkreidon73zkcrwdb5iafqtijxildoonbwnpv7dyd6ef3qdgads2jc4su");

// Convert versions
var v0AsV1 = v0.ToV1();
var v1AsV0 = v0AsV1.ToV0();

// Build from content bytes
var content = Encoding.UTF8.GetBytes("hello world");
var cid = Cid.FromContent(content, codec: Multicodec.Raw, hashCode: MultihashCode.Sha2_256);

// Serialize
string text = cid.ToString(); // CIDv1 defaults to base32 lower
byte[] bytes = cid.ToByteArray();

Specification Notes

Implementation follows the CID spec behavior, including:

  • CIDv0 is always dag-pb + sha2-256(32)
  • CIDv1 binary layout: <cidv1-varint><codec-varint><multihash>
  • CIDv0 string form has no multibase prefix
  • CID versions 2 and 3 are treated as reserved/invalid

Input Limits

Parsing APIs enforce default size limits to reduce memory-pressure risk from untrusted input:

  • Cid.DefaultMaxInputStringLength
  • Cid.DefaultMaxInputByteLength
  • Multibase.DefaultMaxInputLength

Overloads on parse/decode methods let callers provide custom limits when needed.

References:

Development

dotnet restore NetCid.sln
dotnet build NetCid.sln -c Release
dotnet test NetCid.Tests/NetCid.Tests.csproj -c Release
dotnet test NetCid.IntegrationTests/NetCid.IntegrationTests.csproj -c Release

Examples

Reference examples are available under examples/ and mirror the js-multiformats example set:

  • examples/cid-interface
  • examples/multicodec-interface
  • examples/multihash-interface
  • examples/block-interface
  • examples/multibase-interface
  • examples/did-key-interface

See examples/README.md for run commands.

Contributing

See contributors.md for contributor workflow, quality checklist, and PR expectations.

CI / Release

  • CI workflow: .github/workflows/ci.yml
  • Security workflows: .github/workflows/security.yml, .github/workflows/codeql.yml
  • NuGet publish workflow: .github/workflows/release.yml

release.yml pushes packages when a tag like v1.2.3 is pushed (or manual dispatch) and requires NUGET_API_KEY repository secret.

Security

  • Responsible disclosure: see SECURITY.md
  • Security review and findings: see SECURITY_AUDIT.md
Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on NetCid:

Package Downloads
NetDid.Core

Core abstractions, DID document model, crypto primitives, and encoding for the NetDid multi-method DID library.

NetDid.Method.Peer

did:peer method implementation for the NetDid multi-method DID library.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0 436 3/15/2026
1.2.1 157 3/8/2026
1.2.0 82 3/8/2026
1.1.0 665 2/20/2026
1.0.0 94 2/20/2026