Skip to content
0

katanakit-js / useVerifyFileHash

Function: useVerifyFileHash() ​

ts
function useVerifyFileHash(
   path, 
   expected, 
   algorithm?
): Promise<FilesystemResult<boolean>>;

Defined in: src/infrastructure/filesystem/filesystem.service.ts:204

Verifies a file checksum against an expected value (case-insensitive).

Parameters ​

ParameterTypeDefault valueDescription
pathstringundefinedFile path.
expectedstringundefinedExpected hex digest (from a .sha256 sidecar, release page, …).
algorithm"md5" | "sha1" | "sha256" | "sha512""sha256"Algorithm used for both values (default: "sha256").

Returns ​

Promise<FilesystemResult<boolean>>

Safe Result with true when the digests match.

Example ​

ts
const check = await useVerifyFileHash("image.iso", "e3b0c442…");
if (check.ok && !check.data) throw new Error("checksum mismatch");

Released under the MIT License.