Table of Contents

Class ZipStamp

Namespace
VpnHood.Net.Toolkit.Assets
Assembly
VpnHood.Net.Toolkit.dll

Provides the stamp that names a zip's contents: in front of the zip, VHSTAMP:, 16 hex digits and a newline. The digits are the first 16 hex digits of the SHA-256 of the whole file, taken while they were still zero, so the stamp can sit in what it hashes.

public static class ZipStamp
Inheritance
ZipStamp
Inherited Members

Remarks

A zip is read from its end, by offsets that count the stamp, so a zip tool that finds the directory from the end still opens a stamped zip. Reading the stamp reads its 25 bytes alone, even from a stream that only goes forward, such as an Android asset's. A zip without one, such as one a fork packed with its own tool, is read whole and hashed instead, with a warning. StampedZipArchive writes one.

Methods

ReadAsync(Stream, string?, CancellationToken)

Reads the stamp of the zip at the stream's position, or hashes the rest of the stream when there is none.

public static Task<string> ReadAsync(Stream stream, string? zipName, CancellationToken cancellationToken)

Parameters

stream Stream

The stream, at the zip's start; it is read, not closed.

zipName string

The zip's name, for the warning alone, or null.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<string>

A task whose result is the 16 hex digits.

ReadAsync(IAsset, CancellationToken)

Reads a zip's stamp, or hashes the zip when it has none.

public static Task<string> ReadAsync(IAsset zip, CancellationToken cancellationToken)

Parameters

zip IAsset

The zip.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<string>

A task whose result is the 16 hex digits.