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 createSign
instances.Sign
objects are not to be created directly using thenew
keyword.
Example: Using Verify
objects as streams:
1 2 3 4 5 6 7 8 9 10 | 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 false |
Example: Using the verify.update()
and verify.verify()
methods:
1 2 3 4 5 6 7 8 9 | 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.