diffieHellman.computeSecret(otherPublicKey[, inputEncoding][, outputEncoding])
otherPublicKey
<string> | <Buffer> | <TypedArray> | <DataView>inputEncoding
<string>otherPublicKey
字符串的编码。outputEncoding
<string> 返回值的编码。- 返回: <Buffer> | <string>
使用 otherPublicKey
作为对方的公钥计算共享密钥,并返回计算出的共享密钥。
使用指定的 inputEncoding
解释提供的密钥,使用指定的 outputEncoding
对密钥进行编码。
如果未提供 inputEncoding
,则 otherPublicKey
应为 Buffer
、TypedArray
或 DataView
。
如果给定 outputEncoding
,则返回字符串; 否则,返回 Buffer
。
otherPublicKey
<string> | <Buffer> | <TypedArray> | <DataView>inputEncoding
<string> The encoding of anotherPublicKey
string.outputEncoding
<string> The encoding of the return value.- Returns: <Buffer> | <string>
Computes the shared secret using otherPublicKey
as the other
party's public key and returns the computed shared secret. The supplied
key is interpreted using the specified inputEncoding
, and secret is
encoded using specified outputEncoding
.
If the inputEncoding
is not
provided, otherPublicKey
is expected to be a Buffer
,
TypedArray
, or DataView
.
If outputEncoding
is given a string is returned; otherwise, a
Buffer
is returned.