• Hash a File

    Type Parameters

    • const Options extends {
          algorithm?: ArrayOrNot<string>;
          output?: "buffer" | BinaryToTextEncoding;
          salt?: string;
      }

    Parameters

    • file: PathLike
    • Optional options: Options

    Returns Promise<Options["algorithm"] extends any[]
        ? {
            [Key in Options["algorithm"][number]]: Options["output"] extends "buffer"
                ? Buffer
                : string
        }
        : Options["output"] extends "buffer"
            ? Buffer
            : string>

    Example

    import { filesystem } from "@rjweb/utils"

    await filesystem.hash('./doc.txt', { algorithm: 'sha256', salt: '123', output: 'hex' }) // 91be40b8a3959b7821be224d8ce5ad09874fc84dcacd9fed77bf07000141e15a

    Since

    1.12.0

    Supports

    nodejs