Module

std/node/crypto.ts>Hash

Deno standard library
Go to Latest
class Hash
extends Transform
import { Hash } from "https://dotland.deno.dev/std@0.92.0/node/crypto.ts";

The Hash class is a utility for creating hash digests of data. It can be used in one of two ways:

  • As a stream that is both readable and writable, where data is written to produce a computed hash digest on the readable side, or
  • Using the hash.update() and hash.digest() methods to produce the computed hash.

The crypto.createHash() method is used to create Hash instances. Hash objects are not to be created directly using the new keyword.

Constructors

new
Hash(algorithm: SupportedAlgorithm, _opts?: TransformOptions)

Properties

hash: Hasher

Methods

digest(encoding?: string): Buffer | string

Calculates the digest of all of the data.

If encoding is provided a string will be returned; otherwise a Buffer is returned.

Supported encoding is currently 'hex' only. 'binary', 'base64' will be supported in the future versions.

update(data: string | ArrayBuffer, _encoding?: string): this

Updates the hash content with the given data.