class Verify extends stream.Writable
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()andverify.verify()methods to verify the signature.
The crypto.createVerify() method is used to create Verify instances.
Verify objects are not to be created directly using the new keyword.
See Sign for examples.
verify.update
History
inputEncoding changed from binary to utf8.verify.update(data, inputEncoding?): void
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, or
DataView, then inputEncoding is ignored.
This can be called many times with new data as it is streamed.
verify
History
verify(key, signature, signatureEncoding?): boolean
Object | string | ArrayBuffer | Buffer | TypedArray | DataView | KeyObject | CryptoKeystring | ArrayBuffer | Buffer | TypedArray | DataViewbooleantrue or false depending on the validity of the
signature for the data and public key.Verifies the provided data using the given key and signature.
If key is not a KeyObject, this function behaves as if
key had been passed to crypto.createPublicKey(). When key is a string,
ArrayBuffer, Buffer, TypedArray, or DataView, it must contain
PEM-encoded key material. If it is an object, the following additional
properties can be passed:
string(r, s).r || s as proposed in IEEE-P1363.integerintegerRSA_PKCS1_PSS_PADDING. The special value
crypto.constants.RSA_PSS_SALTLEN_DIGEST sets the salt length to the digest
size, crypto.constants.RSA_PSS_SALTLEN_AUTO (default) causes it to be
determined automatically.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.