Module

std/node/crypto.ts

Deno standard library
Go to Latest
class Hash
extends Transform
import { Hash } from "https://deno.land/std@0.145.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: string | DigestContext, _opts?: TransformOptions)

Methods

copy(): Hash
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', 'binary', 'base64'.

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

Updates the hash content with the given data.

import Hash
import { Hash } from "https://deno.land/std@0.145.0/node/crypto.ts";