Table of Contents

Class FileHash

Namespace
Valheim.Testing.Game
Assembly
Valheim.Testing.Game.dll

The toolkit's one owner of hashing: every SHA256 and MD5 this package computes, as lower-case hex. Pins, manifests, listings and evidence checksums are SHA256; plugin pins are MD5 (Md5(string)). Two hashes are computed elsewhere on purpose: a host computes its own listing remotely (sha256sum, or .NET in PowerShell), which Valheim.Testing.Game.FileHash.Listing(System.Collections.Generic.IEnumerable<(string Relative, string Sha256)>) then reads, and a character save's SHA512 is the game's own integrity check, read as the game writes it.

public static class FileHash
Inheritance
object
FileHash

Methods

IsMacMetadata(string)

Finder's .DS_Store and AppleDouble ._* files, which copying through macOS adds; never part of a listing.

public static bool IsMacMetadata(string path)

Parameters

path string

Returns

bool

Md5(string)

A plugin file's MD5 as ValheimCLI reports and compares it (cli_manifest, cli_expect): 32 lower-case hex characters. MD5 stays for plugin pins because the game side computes and compares MD5; a plan's plugin pin must be the value the game reports. It identifies a build; it is not a security check.

public static string Md5(string path)

Parameters

path string

Returns

string

Sha256(Stream)

The SHA256 of the rest of content.

public static string Sha256(Stream content)

Parameters

content Stream

Returns

string

Sha256(ReadOnlySpan<byte>)

The SHA256 of content in memory (a file's bytes before or after it is written, or a digest's input).

public static string Sha256(ReadOnlySpan<byte> content)

Parameters

content ReadOnlySpan<byte>

Returns

string

Sha256(string)

The SHA256 of the file at path.

public static string Sha256(string path)

Parameters

path string

Returns

string

Sha256Async(string, CancellationToken)

The SHA256 of the file at path, read asynchronously.

public static Task<string> Sha256Async(string path, CancellationToken cancellation = default)

Parameters

path string
cancellation CancellationToken

Returns

Task<string>