Class: Verify
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.createSign()method is used to createSigninstances.Signobjects are not to be created directly using thenewkeyword.
Example: Using Verify objects as streams:
const crypto = require('crypto');
const verify = crypto.createVerify('RSA-SHA256');
verify.write('some data to sign');
verify.end();
const public_key = getPublicKeySomehow();
const signature = getSignatureToVerify();
console.log(sign.verify(public_key, signature));
// Prints true or falseExample: Using the verify.update() and verify.verify() methods:
const crypto = require('crypto');
const verify = crypto.createVerify('RSA-SHA256');
verify.update('some data to sign');
const public_key = getPublicKeySomehow();
const signature = getSignatureToVerify();
console.log(verify.verify(public_key, signature));
// Prints true or false
Please login to continue.