Skip to main content
DiffieHellman.prototype.computeSecret - crypto - Node documentation
method DiffieHellman.prototype.computeSecret

Usage in Deno

import { DiffieHellman } from "node:crypto";
DiffieHellman.prototype.computeSecret(
otherPublicKey: ArrayBufferView,
inputEncoding?: null,
outputEncoding?: null,
): 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.

Parameters

otherPublicKey: ArrayBufferView
optional
inputEncoding: null

The encoding of an otherPublicKey string.

optional
outputEncoding: null

The encoding of the return value.

Return Type

Buffer
DiffieHellman.prototype.computeSecret(
otherPublicKey: string,
inputEncoding: BinaryToTextEncoding,
outputEncoding?: null,
): Buffer

Parameters

otherPublicKey: string
inputEncoding: BinaryToTextEncoding
optional
outputEncoding: null

Return Type

Buffer
DiffieHellman.prototype.computeSecret(
otherPublicKey: ArrayBufferView,
inputEncoding: null,
outputEncoding: BinaryToTextEncoding,
): string

Parameters

otherPublicKey: ArrayBufferView
inputEncoding: null
outputEncoding: BinaryToTextEncoding

Return Type

string
DiffieHellman.prototype.computeSecret(
otherPublicKey: string,
inputEncoding: BinaryToTextEncoding,
outputEncoding: BinaryToTextEncoding,
): string

Parameters

otherPublicKey: string
inputEncoding: BinaryToTextEncoding
outputEncoding: BinaryToTextEncoding

Return Type

string
Back to top