crypto.diffieHellman(options[, callback])
-
options
:<Object>-
privateKey
:<KeyObject> -
publicKey
:<KeyObject>
-
-
callback
<Function> -
返回:如果未提供
callback
函数,则为 <Buffer>。¥Returns: <Buffer> if the
callback
function is not provided.
基于 privateKey
和 publicKey
计算 Diffie-Hellman 秘密。两个密钥必须具有相同的 asymmetricKeyType
,该 asymmetricKeyType
必须是 'dh'
(用于 Diffie-Hellman)、'ec'
、'x448'
或 'x25519'
(用于 ECDH)之一。
¥Computes the Diffie-Hellman secret based on a privateKey
and a publicKey
.
Both keys must have the same asymmetricKeyType
, which must be one of 'dh'
(for Diffie-Hellman), 'ec'
, 'x448'
, or 'x25519'
(for ECDH).
如果提供了 callback
函数,则该函数使用 libuv 的线程池。
¥If the callback
function is provided this function uses libuv's threadpool.