Skip to main content
DiffieHellman.prototype.generateKeys - node__crypto.d.ts - Node documentation
method DiffieHellman.prototype.generateKeys

Usage in Deno

```typescript import { DiffieHellman } from "node:node__crypto.d.ts"; ```
DiffieHellman.prototype.generateKeys(): Buffer
Generates private and public Diffie-Hellman key values unless they have been generated or computed already, and returns the public key in the specified `encoding`. This key should be transferred to the other party. If `encoding` is provided a string is returned; otherwise a `Buffer` is returned. This function is a thin wrapper around [`DH_generate_key()`](https://www.openssl.org/docs/man3.0/man3/DH_generate_key.html). In particular, once a private key has been generated or set, calling this function only updates the public key but does not generate a new private key.

Return Type

Buffer
DiffieHellman.prototype.generateKeys(encoding: BinaryToTextEncoding): string

Parameters

Return Type

string