crypto.diffieHellman(options[, callback])
options<Object>privateKey<Object> | <string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> | <KeyObject>publicKey<Object> | <string> | <ArrayBuffer> | <Buffer> | <TypedArray> | <DataView> | <KeyObject>
callback<Function>- 返回:<Buffer> 如果未提供
callback函数。
根据 privateKey 和 publicKey 计算 Diffie-Hellman 共享密钥。两把密钥必须表示相同的不对称密钥类型,并且必须支持 DH 或 ECDH 操作。
🌐 Computes the Diffie-Hellman shared secret based on a privateKey and a publicKey.
Both keys must represent the same asymmetric key type and must support either the DH or
ECDH operation.
如果 options.privateKey 不是 KeyObject,则此函数的行为就像将 options.privateKey 传递给 crypto.createPrivateKey() 一样。
🌐 If options.privateKey is not a KeyObject, this function behaves as if
options.privateKey had been passed to crypto.createPrivateKey().
如果 options.publicKey 不是 KeyObject,则此函数的行为就像将 options.publicKey 传递给 crypto.createPublicKey() 一样。
🌐 If options.publicKey is not a KeyObject, this function behaves as if
options.publicKey had been passed to crypto.createPublicKey().
如果提供了 callback 函数,该函数会使用 libuv 的线程池。
🌐 If the callback function is provided this function uses libuv's threadpool.