TorrentUtils 0.1.0

dotnet add package TorrentUtils --version 0.1.0
                    
NuGet\Install-Package TorrentUtils -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="TorrentUtils" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="TorrentUtils" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="TorrentUtils" />
                    
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 TorrentUtils --version 0.1.0
                    
#r "nuget: TorrentUtils, 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 TorrentUtils@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=TorrentUtils&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=TorrentUtils&version=0.1.0
                    
Install as a Cake Tool

TorrentUtils

TorrentUtils is a C# rewrite of airium/TorrentUtils. It provides BitTorrent metadata APIs for parsing, writing, hashing, top-level metadata rewriting, and payload verification.

The library is focused on BEP 3 / v1 torrent metadata. It also exposes a lightweight meta version probe so callers can identify v2 metadata before choosing a parsing path.

Install

dotnet add package TorrentUtils

Basic Usage

Read metadata and compute the v1 info hash:

using TorrentUtils;

using var torrent = new Torrent();
torrent.ReadTorrentFile("sample.torrent");

Console.WriteLine(torrent.Name);
Console.WriteLine(torrent.ComputeInfoHashHex());

foreach (var file in torrent.FileList)
{
    Console.WriteLine($"{file.RelativePath} {file.Size}");
}

Create a v1 torrent from a file or directory:

using TorrentUtils;

using var torrent = new Torrent(pieceLength: 4 * 1024 * 1024);
torrent.SetTrackerList(["https://tracker.example/announce"]);
torrent.SetCreatedBy("TorrentUtils");

await torrent.LoadFromPathAsync(new DirectoryInfo("payload"));
torrent.WriteTorrentFile("payload.torrent");

Verify payload bytes against an existing torrent:

using TorrentUtils;

using var torrent = new Torrent();
torrent.ReadTorrentFile("payload.torrent");

IReadOnlyList<int> failedPieces = torrent.Verify("payload");

Probe the torrent metadata version:

using TorrentUtils;

int version = TorrentVersion.ReadMetaVersionFromFile("sample.torrent");
bool isV2 = TorrentVersion.IsV2FromFile("sample.torrent");

Rewrite top-level metadata without changing the info dictionary:

using TorrentUtils;

var update = new TorrentTopLevelUpdate();
update.SetComment("Updated comment");
update.SetCreatedBy("TorrentUtils");

TorrentTopLevelRewriter.RewriteFile("input.torrent", "output.torrent", update);
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.  net9.0 was computed.  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 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.
  • net10.0

    • No dependencies.
  • 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
0.1.0 51 7/7/2026