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 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 crypto
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.
Hash Value : 5a302d3c930d9e938c5326d7bb863afdc024b9ce77e30e99c4b82983350f8196
Hash Value : e0789790d7da870830a679828c722f74f3840d4a6483f5babfb62c4d19884c9e