crypto.getHashes() Method in Node.js


The crypto.getHashes() method will return an array that contains names of all the supported hash algorithms. The crypto package has a huge list of hash algorithms we can use. But the most used cipher algorithm is 'MD5 – Message-Digest Algorithm5 '.

Syntax

crypto.getHashes()

Parameters

Since it returns a list of all the hash algorithms. It does not need to have any input.

Example

Create a file with name – getHashes.js and copy the below code snippet. After creating file, use the following command to run this code as shown in the example below −

node getHashes.js

getHashes.js

 Live Demo

// A node demo program for getting all hash algorithms

// Importing the crypto module
const crypto = require('crypto');

// Calling the getHashes() method
const cipher = crypto.getHashes();

// Printing the list of all the algorithms there is
console.log("The list of all hash algorithm are as follows: ", cipher);

Output

C:\home
ode>> node getCipher.js The list of all hash algorithm are as follows: [ 'RSA-MD4',    'RSA-MD5',    'RSA-RIPEMD160',    'RSA-SHA1',    'RSA-SHA1-2',    'RSA-SHA224',    'RSA-SHA256',    'RSA-SHA3-224',    'RSA-SHA3-256',    'RSA-SHA3-384',    'RSA-SHA3-512',    'RSA-SHA384',    'RSA-SHA512',    'RSA-SHA512/224',    'RSA-SHA512/256',    'RSA-SM3',    'blake2b512',    'blake2s256',    'id-rsassa-pkcs1-v1_5-with-sha3-224',    'id-rsassa-pkcs1-v1_5-with-sha3-256',    'id-rsassa-pkcs1-v1_5-with-sha3-384',    'id-rsassa-pkcs1-v1_5-with-sha3-512',    'md4',    'md4WithRSAEncryption',    'md5',    'md5-sha1',    'md5WithRSAEncryption',    'ripemd',    'ripemd160',    'ripemd160WithRSA',    'rmd160',    'sha1',    'sha1WithRSAEncryption',    'sha224',    'sha224WithRSAEncryption',    'sha256',    'sha256WithRSAEncryption',    'sha3-224',    'sha3-256',    'sha3-384',    'sha3-512',    'sha384',    'sha384WithRSAEncryption',    'sha512',    'sha512-224',    'sha512-224WithRSAEncryption',    'sha512-256',    'sha512-256WithRSAEncryption',    'sha512WithRSAEncryption',    'shake128',    'shake256',    'sm3',    'sm3WithRSAEncryption',    'ssl3-md5',    'ssl3-sha1',    'whirlpool' ]

Updated on: 20-May-2021

102 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements