當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


Node.js crypto.getHashes()用法及代碼示例


crypto.getHashes()方法是加密模塊的內置應用程序編程接口,用於顯示數組中所有受支持的哈希算法的名稱。

用法:

crypto.getHashes()

參數:此方法不接受任何參數。



返回值:它返回所有受支持的哈希算法的名稱。

以下示例說明了Node.js中crypto.getHashes()方法的使用:

例:

// Node.js program to demonstrate the  
// crypto.getHashes() method 
  
// Including crypto module 
const crypto = require('crypto'); 
  
// Calling getHashes method 
const hash = crypto.getHashes(); 
  
// Prints all the supported hash algorithms 
console.log("The list of all the hash "
        + "algorithms are:", hash);

輸出:

The list of all the hash algorithms are: [ 'RSA-MD4',
  'RSA-MD5',
  'RSA-MDC2',
  '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',
  'mdc2',
  'mdc2WithRSA',
  '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' ]

參考: https://nodejs.org/api/crypto.html#crypto_crypto_gethashes




相關用法


注:本文由純淨天空篩選整理自nidhi1352singh大神的英文原創作品 Node.js | crypto.getHashes() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。