import { Hash } from "https://dotland.deno.dev/std@0.177.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
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 encodings are currently 'hex', 'binary', 'base64', 'base64url'.
update(data: string | ArrayBuffer, _encoding?: string): this
Updates the hash content with the given data.