Node.js verify.verify(object, signature[, signatureEncoding]) Method Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will discuss about the verify.verify() method in the Verify Class of the crypto module in NodeJS. The verify class utility is used for verifying the signature. This method verifies the signature by providing the given data object and signature. The verify object can not be used again after verify.verify() has been called. Multiple times to call verify.verify() method will result in an error being thrown. Syntax: verify.verify(object, signature, signatureEncoding) Parameter: This method accepts three parameters as mentioned above: object: This will be the object that has to be verified. It can be of the type Object, string, ArrayBuffer, Buffer, TypedArray, DataView, KeyObject or CryptoKey.signature: This parameter defines which type of signature using like string, ArrayBuffer, Buffer, TypedArray or DataView.signatureEncoding: This parameter specifies the encoding of the data. Returns: This method returns a Boolean value. If the signature matches, then it will return true, otherwise false. Example 1: In the below example, we will verify the two signatures. In this case, as both signatures are the same so it will return true. JavaScript const crypto = require('crypto'); const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', { modulusLength: 2048, }); const sign = crypto.createSign('SHA256'); sign.update('GeeksforGeeks'); sign.end(); const signature = sign.sign(privateKey); const verify = crypto.createVerify('SHA256'); verify.update('GeeksforGeeks') verify.end(); console.log(verify.verify(publicKey, signature)); Output: true Example 2: In the below example, We are verifying the two different signatures. JavaScript const crypto = require('crypto'); const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', { modulusLength: 2048, }); const sign = crypto.createSign('SHA256'); sign.update('GeeksforGeeks'); sign.end(); const signature = sign.sign(privateKey); const verify = crypto.createVerify('SHA256'); verify.update('Not Same') verify.end(); console.log(verify.verify(publicKey, signature)); Output: false Reference: https://nodejs.org/api/crypto.html#verifyverifyobject-signature-signatureencoding Comment More infoAdvertise with us Next Article Node.js verify.verify(object, signature[, signatureEncoding]) Method N neeraj3304 Follow Improve Article Tags : Web Technologies Node.js Node.js-Methods Node.js-crypto-module Similar Reads Node.js http.validateHeaderValue() Method The http.validateHeaderValue() (Added in v14.3.0) property is an inbuilt property of the âhttpâ module which performs the low-level validations on the provided value that are done when res.setHeader(name, value) is called. Passing an illegal value as the value will result in a TypeError being thrown 3 min read Node.js x509.toString() Method The x509.toString() is an inbuilt application programming interface of class X509Certificate within crypto module which is used to get the PEM-encoded certificate. Syntax: const x509.toString() Parameters: This method does not accept any arguments as a parameter. Return Value: This method returns th 2 min read How to check if a string is valid MongoDB ObjectId in Node.js ? Checking if a string is valid mongoDB ObjectID is important while working with databases. It ensures accurate reference the the objects in databases. We can validate the ObjectId with the help of isValid function in MongoDB.Prerequisites:NodeJS and NPM installedMongoose and MongoDBTable of ContentMo 3 min read Node.js verify.update(data[, inputEncoding]) Method The verify.update() method is an inbuilt method in verify class within the crypto module in NodeJs. This method verifies the content within the given data. When the input encoding parameter is not specified and it detects that the data is a string, the 'utf8' encoding is used. However, if the data i 2 min read Node.js x509.toLegacyObject() Method The x509.toLegacyObject() is  an inbuilt application programming interface of class X509Certificate within crypto module which is used to get  information about this certificate using the legacy certificate object encoding. Syntax: const x509.toLegacyObject() Parameters: This method does not accept 2 min read Like