Skip to content
0

katanakit-js / useHashFile

Function: useHashFile() ​

ts
function useHashFile(path, algorithm?): Promise<FilesystemResult<string>>;

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

Streams a file and returns its checksum as a lowercase hex digest.

Parameters ​

ParameterTypeDefault valueDescription
pathstringundefinedFile path.
algorithm"md5" | "sha1" | "sha256" | "sha512""sha256"`"md5"

Returns ​

Promise<FilesystemResult<string>>

Safe Result with the hex digest.

Example ​

ts
const result = await useHashFile("image.iso"); // sha256
const md5 = await useHashFile("image.iso", "md5");

Released under the MIT License.