The crypto.createHash() method is used to create a Hash object that can be used to create hash digests by using the stated algorithm.
crypto.createHash( algorithm, options )
Parameters: This method accept two parameters as mentioned avobe and described below:
- algorithm: It is dependent on the accessible algorithms which are favored by the version of OpenSSL on the platform. It returns string. The examples are sha256, sha512, etc.
- options: It is optional parameter and is used to control stream behavior. It returns an object. Moreover, For XOF hash functions like ‘shake256’, the option outputLength can be used to determine the required output length in bytes.
Return Type: It returns Hash object.
Below examples illustrate the use of crypto.createHash() method in Node.js:
Program done! n95mt3468ZzAIwu/bbNU7dej6CoFkDRcNaJo7rGpLF4= index.js