FastRsyncNet 2.4.8

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

FastRsyncNet - C# delta syncing library

FastRsyncNet is a .NET library for efficient file synchronization based on the Rsync algorithm. Instead of transferring a whole file when it changes, it transfers only the parts that differ, which makes it well suited for keeping large files in sync over the network (for example content stored in Azure Blob Storage).

It works in three steps:

  1. Signature - from a basis file (the version the other side already has) you compute a compact signature describing its blocks.
  2. Delta - given the signature and the new file, you compute a delta containing only the blocks that changed plus instructions to copy the unchanged blocks.
  3. Patch - the delta is applied to the basis file to reconstruct the new file, and the result is verified with a whole-file hash.

Capabilities at a glance:

  • Multiple hashing algorithms (xxHash64, xxHash3, SHA1, MD5) - the default xxHash64 is much faster and produces smaller signatures than SHA1.
  • Multiple rolling checksum algorithms with different speed/quality trade-offs.
  • Fully synchronous and asynchronous (async/await, with CancellationToken) APIs.
  • Streaming design that works directly on network-backed streams such as Azure Blob.
  • Single-pass signature building that reads the basis file only once - roughly twice as fast over the network.
  • Optional rsync-friendly GZip compression via the companion FastRsyncNet.Compression package.

Install NuGet

Add to a project via NuGet:

  1. Right click on a project and click 'Manage NuGet Packages'.
  2. Search for 'FastRsyncNet' and click 'Install'.

Supported target frameworks: .NET Framework 4.6.2, .NET Standard 2.0, and .NET 7.0 / 8.0 / 9.0 / 10.0.

Examples

Calculating signature

using FastRsync.Signature;

...

var signatureBuilder = new SignatureBuilder(SupportedAlgorithms.Hashing.XxHash3(), SupportedAlgorithms.Checksum.Adler32RollingV3());
using (var basisStream = new FileStream(basisFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var signatureStream = new FileStream(signatureFilePath, FileMode.Create, FileAccess.Write, FileShare.Read))
{
    signatureBuilder.Build(basisStream, new SignatureWriter(signatureStream));
}

Calculating delta

using FastRsync.Core;
using FastRsync.Delta;
using FastRsync.Diagnostics;
using FastRsync.Signature;

...

var deltaBuilder = new DeltaBuilder();
deltaBuilder.ProgressReport = new ConsoleProgressReporter();
using (var newFileStream = new FileStream(newFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var signatureStream = new FileStream(signatureFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var deltaStream = new FileStream(deltaFilePath, FileMode.Create, FileAccess.Write, FileShare.Read))
{
    deltaBuilder.BuildDelta(newFileStream, new SignatureReader(signatureStream, null),
        new AggregateCopyOperationsDecorator(new BinaryDeltaWriter(deltaStream)));
}

Patching (applying delta)

By default the applied result is verified: the whole-file hash stored in the delta is compared against the hash of the reconstructed file, and a mismatch throws. See Security considerations for what that check does and does not guarantee.

using FastRsync.Delta;

...

var deltaApplier = new DeltaApplier();
using (var basisStream = new FileStream(basisFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var deltaStream = new FileStream(deltaFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var newFileStream = new FileStream(newFilePath, FileMode.Create, FileAccess.ReadWrite, FileShare.Read))
{
    deltaApplier.Apply(basisStream, new BinaryDeltaReader(deltaStream, null), newFileStream);
}

Set deltaApplier.SkipHashCheck = true to skip the verification (for example when the output stream is not seekable, since the check needs to re-read the output).

Asynchronous usage

All of the operations above have async counterparts (BuildAsync, BuildDeltaAsync, ApplyAsync), each accepting an optional CancellationToken. This is the preferred path for network-backed streams.

using FastRsync.Delta;
using FastRsync.Signature;

...

var deltaBuilder = new DeltaBuilder();
using (var newFileStream = new FileStream(newFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var signatureStream = new FileStream(signatureFilePath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var deltaStream = new FileStream(deltaFilePath, FileMode.Create, FileAccess.Write, FileShare.Read))
{
    await deltaBuilder.BuildDeltaAsync(newFileStream, new SignatureReader(signatureStream, null),
        new AggregateCopyOperationsDecorator(new BinaryDeltaWriter(deltaStream)), cancellationToken);
}

Calculating signature on network stream (Azure blobs)

The examples below use the modern Azure.Storage.Blobs SDK. The input stream must be seekable; OpenReadAsync returns a seekable stream, so blobs work directly.

using Azure.Storage.Blobs;
using FastRsync.Signature;

...

var containerClient = new BlobServiceClient("azure storage connectionstring").GetBlobContainerClient("containerName");
var basisBlob = containerClient.GetBlockBlobClient("blobName");
var signatureBlob = containerClient.GetBlockBlobClient("blob_signature");

var signatureBuilder = new SignatureBuilder(SupportedAlgorithms.Hashing.XxHash3(), SupportedAlgorithms.Checksum.Adler32RollingV3());
using (var basisStream = await basisBlob.OpenReadAsync())
using (var signatureStream = await signatureBlob.OpenWriteAsync(overwrite: true))
{
    await signatureBuilder.BuildAsync(basisStream, new SignatureWriter(signatureStream), cancellationToken);
}

Performance tuning

  • SignatureBuilder.SinglePassBuild (default true) - the basis file is read only once; the verification hash is computed incrementally while the chunk signatures are gathered. This roughly halves the I/O and is about twice as fast when the basis file is a network-backed stream. The produced signature is byte-for-byte identical to the two-pass output. It buffers the chunk signatures in memory (about 1% of the basis file size); set it to false to stream them directly at the cost of reading the basis file twice.
  • DeltaBuilder.SkipDeltaIfHashesMatch (default false, opt-in) - when the new file's hash matches the basis file hash recorded in the signature, delta building skips scanning the file entirely and emits a minimal delta. Building deltas for unchanged files becomes almost free. Because it relies on hash equality, do not enable it if an adversary might supply colliding inputs.
  • Metadata file lengths - signatures record the basis file length; deltas record the basis and target file lengths. DeltaApplier uses the target length to preallocate the output when writing to a fresh seekable stream. These fields are ignored by older versions.
  • UseBufferPool on DeltaBuilder, DeltaApplier and BinaryDeltaReader (default true) - rents the multi-megabyte working buffer from the shared array pool instead of allocating it per operation. This removes a large-object-heap allocation per operation, which reduces GC pressure noticeably when many operations run in the same process (e.g. a server). It does not change the output. Set it to false for one-shot or memory-sensitive local use, where the pool retaining buffers between operations is not worthwhile.

Available algorithms and relative performance

Following signature hashing algorithms are available:

  • XxHash64 - default algorithm, signature size 6.96 MB, signature calculation time 5209 ms.
  • XxHash3 - signature size 6.96 MB, signature calculation time 5024 ms. For all new use cases, use this one.
  • SHA1 - signature size 12.9 MB, signature calculation time 6519 ms.
  • MD5 - originally used in Rsync program, signature size 10.9 MB, signature calculation time 6767 ms.

The signature sizes and calculation times are relative indicators only, measured against a 0.99 GB file on one machine; real performance on your system will vary greatly.

Following rolling checksum algorithms are available:

  • Adler32RollingChecksum - default algorithm, it uses low level optimization that makes it faster but provides worse quality of checksum.
  • Adler32RollingChecksumV2 - Obsolete (using it produces a compiler warning). It has a bug that - while it does not make any data incorrect - results in unnecessarily big deltas. Do not use it, unless you need to for backward compatibility. It is the original (but incorrectly implemented) Adler32 algorithm (slower but better quality of checksum).
  • Adler32RollingChecksumV3 - for all new use cases, use this one. It is fast and has the best quality of checksum.

GZip compression that is rsync compatible NuGet

If you synchronize a compressed file, a small change in a compressed file may force rsync algorithm to synchronize the whole compressed file, instead of just the changed blocks. To fix this, a custom GZip compression method may be used that periodically resets the compressor state to make it block-sync friendly. Install FastRsyncNet.Compression package and use following method:

FastRsync.Compression.GZip.Compress(Stream sourceStream, Stream destStream)

To uncompress you may use any GZip method (e.g. System.IO.Compression.GZipStream).

Compatibility

FastRsyncNet is derived from the Octodiff tool. Unlike Octodiff, which is based on the SHA1 algorithm, FastRsyncNet offers a variety of hashing algorithms to choose from - the default xxHash64 offers significantly faster calculations and a smaller signature size than SHA1 while still providing sufficient hash quality. FastRsyncNet also supports SHA1 and is 100% compatible with signatures and deltas produced by Octodiff.

Version guarantees:

  • FastRsyncNet 2.x can read signatures and deltas produced by FastRsyncNet 1.x and by Octodiff.
  • Files produced by FastRsyncNet 2.x are not recognized by FastRsyncNet 1.x (the signature and delta format changed in 2.0.0).
  • All 2.x releases are mutually compatible: files produced by any 2.x version can be read by any other 2.x version. Newer 2.x releases may add optional fields to the metadata, which older 2.x readers safely ignore.

Security considerations

The verification performed while applying a delta compares the reconstructed file against a hash that is stored inside the delta. This reliably detects a corrupted delta or a basis file that does not match the one the delta was built against, but it does not authenticate the delta itself - an attacker who supplies the delta also controls the hash it is checked against. If deltas can come from an untrusted source, authenticate them out of band (for example with a digital signature or MAC over the delta bytes) before applying them.

License

FastRsyncNet is licensed under the Apache License 2.0.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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 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 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 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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on FastRsyncNet:

Repository Stars
POW-Software/ByteSync
ByteSync is a free and open-source tool for file synchronization, backup, and deduplication. It works locally or remotely, with no VPNs or firewall configuration required. Transfers only file differences, compresses data, encrypts end-to-end, and gives you full control over what and when to sync. Runs on Windows, Linux, and macOS.
Version Downloads Last Updated
2.4.8 44 7/23/2026
2.4.7 86 7/21/2026
2.4.6 81 7/21/2026
2.4.5 4,434 2/12/2026
2.4.4 6,458 9/1/2025
2.4.3 11,950 1/2/2025
2.4.2 2,797 10/17/2024
2.4.1 782 8/26/2024
2.4.0 6,229 11/28/2023
2.3.2 1,647 11/1/2023
2.3.1 46,933 11/15/2019
2.3.0 11,703 9/17/2018
2.2.1 1,433 8/17/2018
2.2.0 1,627 8/12/2018
2.1.0 1,918 6/22/2018
2.0.0 1,930 11/24/2017
2.0.0-beta2 1,232 11/22/2017
2.0.0-beta 1,303 11/20/2017
1.2.0 1,393 11/8/2017
1.1.2 8,691 2/7/2017
Loading failed