Node.js verify.update(data[, inputEncoding]) Method Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 is the type of Buffer, TypedArray or DataView, then any specified input encoding is ignored. Syntax: verify.update(data, inputEncoding) Parameters: This method accepts the following parameters as mentioned above: data: This parameter defines the type of data like string, TypeArray, Buffer or DataView.inputEncoding: This parameter defines the encoding type of the input. Returns: This method does not return any value. Example 1: In this example, we will see how to use the update method for verifying the hash. JavaScript const crypto = require('crypto'); const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', { modulusLength: 2048, }); const sign = crypto.createSign('SHA256'); // Both strings should be same sign.update('GeeksforGeeks'); sign.end(); const signature = sign.sign(privateKey); const verify = crypto.createVerify('SHA256'); // Both strings should be same verify.update('GeeksforGeeks'); verify.end(); console.log(verify.verify(publicKey, signature)); Output: true Example 2: Below the example, we are changing the content of the data then we will verify the content of the data by using verify.update() method. JavaScript const crypto = require('crypto'); const { privateKey, publicKey } = crypto.generateKeyPairSync('rsa', { modulusLength: 2048, }); const sign = crypto.createSign('SHA256'); // Both strings should be same sign.update('GeeksforGeeks'); sign.end(); const signature = sign.sign(privateKey); const verify = crypto.createVerify('SHA256'); // Both strings should be same verify.update('GeeksforGeeks Not Same') verify.end(); console.log(verify.verify(publicKey, signature)); Output: false Reference: https://nodejs.org/api/crypto.html#verifyupdatedata-inputencoding Comment More infoAdvertise with us Next Article Node.js verify.update(data[, inputEncoding]) Method N neeraj3304 Follow Improve Article Tags : Web Technologies Node.js Node.js-Methods Node.js-crypto-module Similar Reads Node.js sign.update(data[, inputEncoding]) Method In this article, we will discuss about the sign.update() method in the sign class of the crypto module in NodeJS. This method updates the sign content with the given data and input encoding. If the provided data object is a Buffer, TypeArray, or DataView, then any given inputEncoding parameter is ig 2 min read Node.js decipher.update() Method The decipher.update() method is an inbuilt application programming interface of class Decipher within crypto module which is used to update the decipher with the data according to the given encoding format. Syntax: const decipher.update(data[, inputEncoding][, outputEncoding]) Parameters: This metho 2 min read Node.js hmac.update() Method The hmac.update() method is an inbuilt method of class HMAC within the crypto module which is used to update the data of hmac object. Syntax: hmac.update(data[, inputEncoding])Parameters: This method takes the following two parameters: data: It can be of string, Buffer, TypedArray, or DataView type 2 min read Node.js Buffer.isEncoding() Method The Buffer.isEncoding() method checks whether the given encoding is supported or not. This method returns a Boolean value either true or false. Syntax: Buffer.isEncoding( encoding ) Parameters: This method accepts single parameter encoding which holds the encoding name. The supported encoding are as 1 min read Node.js hash.update() Method The hash.update( ) method is an inbuilt function of the crypto moduleâs Hash class. This is used to update the hash with given data. This method can be called multiple times to update the content of the hash as this method can take streaming data, such as file read stream. This function takes data a 2 min read Like