• Hash a String

    Type Parameters

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

    Parameters

    • input: string
    • Optional options: Options

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

    Example

    import { string } from "@rjweb/utils"

    string.hash('Hello', { algorithm: 'sha256', salt: '123', output: 'hex' }) // 91be40b8a3959b7821be224d8ce5ad09874fc84dcacd9fed77bf07000141e15a

    Since

    1.0.0

    Supports

    nodejs