easy-crypto/hash

The hash module contains a small set of utilities for computing hashes.

Source:

Methods

(static) hash(algorithm, message, inputEncoding, outputEncoding) → {string|Buffer}

Hash a given message using the specified hash algorithm.

Since:
  • 0.1.0
Source:
Parameters:
Name Type Description
algorithm string

The hashing algorithm to be used.

message Data

The message to be hashed.

inputEncoding string

The encoding of the message. If nothing is provided and message is a string, an encoding of 'utf8' is enforced. If message is a Buffer, TypedArray, or DataView, then inputEncoding is ignored.

outputEncoding string

The encoding of the output. If encoding is provided a string will be returned; otherwise a Buffer is returned.

Returns:
Type:
string | Buffer

The hash of the input message.

(async, static) hashStream(algorithm, input, inputEncoding, outputEncoding) → {Promise.<(string|Buffer)>}

Hash a message encapsulated inside a stream using the specified hash algorithm.

Since:
  • 0.1.0
Source:
Parameters:
Name Type Description
algorithm string

The hashing algorithm to be used.

input ReadableStream.<Data>

The stream containing the message to be hashed.

inputEncoding string

The encoding of the message. If nothing is provided and message is a string, an encoding of 'utf8' is enforced. If message is a Buffer, TypedArray, or DataView, then inputEncoding is ignored.

outputEncoding string

The encoding of the output. If encoding is provided a string will be returned; otherwise a Buffer is returned.

Returns:
Type:
Promise.<(string|Buffer)>

The hash of the input message.