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


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

【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.】

如果提供了 outputEncoding,则返回一个字符串;否则,返回一个 Buffer

【If outputEncoding is given a string is returned; otherwise, a Buffer is returned.】