- Version: v11.6.0
- Platform: macOS Mojave (10.14.2) Darwin C02TT3JQHTD6 18.2.0 Darwin Kernel Version 18.2.0: Mon Nov 12 20:24:46 PST 2018; root:xnu-4903.231.4~2/RELEASE_X86_64 x86_64
From crypto.generateKeyPair documentation
If a publicKeyEncoding or privateKeyEncoding was specified, this function behaves as if keyObject.export() had been called on its result. Otherwise, the respective part of the key is returned as a KeyObject.
This documentation part is missing from crypto.generateKeyPairSync but you can still omit the encoding objects, then a simple empty object {} is returned instead of an expected KeyObject.
/cc @tniessen
Examples:
const { generateKeyPairSync } = require('crypto')
console.log('generateKeyPairSync result', generateKeyPairSync('rsa', { modulusLength: 2048 }))
// => generateKeyPairSync result { publicKey: {}, privateKey: {} }