Node.js hash.update() Method Last Updated : 03 Apr, 2023 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 as an argument to generate the hash, this can be a string or file object. Along with the data, this also takes encoding type for the data, this can be utf-8, binary, or ASCII. If encoding is not provided and data is a string then utf-8 is used. desired output length in bytes. Module Installation: Install the required module using the following command: npm install cryptoSyntax: hash.update(data [,Encoding])Parameter: This function takes the following two parameters: data: Data that needs to be added to the hash.encoding: Encoding type for the data.Return Value: This method returns an object with updated data. Example 1: JavaScript // Import crypto module const crypto = require('crypto'); // Create Hash instance with createHash const hash = crypto.createHash('sha256') // Use update to add data .update('I love GeeksForGeeks') // Use digest to get the hash value .digest('hex'); // Prints the hash value console.log("Hash Value : " + hash); Output: Hash Value : 5a302d3c930d9e938c5326d7bb863afdc024b9ce77e30e99c4b82983350f8196Example 2: JavaScript // Import crypto module const crypto = require('crypto'); // Create Hash instance with createHash const hash = crypto.createHash('sha256') // Use update to add data .update('I love GeeksForGeeks') // Use update to add data .update('Because I love coding') // Use digest to get the hash value .digest('hex'); // Prints the hash value console.log("Hash Value : " + hash); Output: Hash Value : e0789790d7da870830a679828c722f74f3840d4a6483f5babfb62c4d19884c9eReference: https://nodejs.org/api/crypto.html#crypto_hash_update_data_inputencoding Comment More infoAdvertise with us Next Article Node.js hash.update() Method A adityapande88 Follow Improve Article Tags : Web Technologies Node.js Node.js-Methods Node.js-crypto-module Similar Reads 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 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 hash.copy() Method The hash.copy( ) method is an inbuilt function of the crypto moduleâs Hash class. This method is used to make a copy of the current state of the hash. This method can be called multiple times to create multiple copies of the hash. This method will throw an error if called after the digest method has 3 min read Lodash _.update() Method Lodash _.update() method accepts an updater to produce the value to set. This method uses _.updateWith() function to customize path creation. It is almost the same as the _.set() function. Syntax:_.update(object, path, updater);Parameters: object: This parameter holds the object to modify.path: This 2 min read Node.js hash.digest() Method The hash.digest( ) method is an inbuilt function of the crypto module's Hash class. This is used to create the digest of the data which is passed when creating the hash. For example, when we create a hash we first create an instance of Hash using crypto.createHash() and then we update the hash conte 3 min read Like