Verify - Node documentation
class Verify
extends stream.Writable

Usage in Deno

import { Verify } from "node:crypto";

The Verify class is a utility for verifying signatures. It can be used in one of two ways:

  • As a writable stream where written data is used to validate against the supplied signature, or
  • Using the verify.update() and verify.verify() methods to verify the signature.

The createVerify method is used to create Verify instances.Verify objects are not to be created directly using the new keyword.

See Sign for examples.

Constructors

new
Verify()

Methods

Updates the Verify content with the given data, the encoding of which is given in inputEncoding. If inputEncoding is not provided, and the data is a string, an encoding of 'utf8' is enforced. If data is a Buffer, TypedArray, orDataView, then inputEncoding is ignored.

This can be called many times with new data as it is streamed.

update(
data: string,
inputEncoding: Encoding,
): Verify
verify(): boolean

Verifies the provided data using the given object and signature.

If object is not a KeyObject, this function behaves as ifobject had been passed to createPublicKey. If it is an object, the following additional properties can be passed:

The signature argument is the previously calculated signature for the data, in the signatureEncoding. If a signatureEncoding is specified, the signature is expected to be a string; otherwise signature is expected to be a Buffer,TypedArray, or DataView.

The verify object can not be used again after verify.verify() has been called. Multiple calls to verify.verify() will result in an error being thrown.

Because public keys can be derived from private keys, a private key may be passed instead of a public key.

verify(): boolean