Node.js 中的 crypto.getHashes() 方法
crypto.getHashes() 方法将返回包含所有受支持哈希算法名称的数组。crypto 包含一个我们可以使用的哈希算法列表。但最常用的加密算法是 'MD5 – 消息摘要算法 5 '。
语法
crypto.getHashes()
参数
由于它返回所有哈希算法的列表。因此它不需要任何输入。
示例
创建文件名称为 getHashes.js,然后复制以下代码段。创建文件后,使用以下命令运行此代码,如下例所示 −
node getHashes.js
getHashes.js
// 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);
输出
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' ]
广告