subtle.digest(algorithm, data)


使用由 algorithm 指定的方法,该方法尝试生成 data 的摘要。如果成功,返回的 Promise 将被解决,并返回包含计算出摘要的 <ArrayBuffer>

【Using the method identified by algorithm, this method attempts to generate a digest of data. If successful, the returned promise is resolved with an <ArrayBuffer> containing the computed digest.】

如果 algorithm 被提供为 <string>,它必须是以下之一:

【If algorithm is provided as a <string>, it must be one of:】

  • 'cSHAKE128'[^现代算法]
  • 'cSHAKE256'[^现代算法]
  • 'SHA-1'
  • 'SHA-256'
  • 'SHA-384'
  • 'SHA-512'
  • 'SHA3-256'[^现代算法]
  • 'SHA3-384'[^现代算法]
  • 'SHA3-512'[^现代算法]

如果 algorithm 作为 <Object> 提供,它必须有一个 name 属性,其值必须是上述之一。

【If algorithm is provided as an <Object>, it must have a name property whose value is one of the above.】