diffieHellman.computeSecret(otherPublicKey[, inputEncoding][, outputEncoding])


使用 otherPublicKey 作为对方的公钥计算共享密钥,并返回计算出的共享密钥。 使用指定的 inputEncoding 解释提供的密钥,使用指定的 outputEncoding 对密钥进行编码。 如果未提供 inputEncoding,则 otherPublicKey 应为 BufferTypedArrayDataView

如果给定 outputEncoding,则返回字符串; 否则,返回 Buffer

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.