Node.js/crypto:修订间差异
来自康健生活
| 第66行: | 第66行: | ||
// encoding: 'utf8' | // encoding: 'utf8' | ||
// padding: crypto.constants.RSA_PKCS1_PSS_PADDING | // padding: crypto.constants.RSA_PKCS1_PSS_PADDING | ||
});</syntaxhighlight> | |||
== crypto. generateKeyPairSync == | |||
<syntaxhighlight lang="javascript"> | |||
const { generateKeyPairSync } = require('crypto'); | |||
const { publicKey, privateKey } = generateKeyPairSync('rsa', { | |||
modulusLength: 4096, // the length of your key in bits | |||
publicKeyEncoding: { | |||
type: 'spki', // recommended to be 'spki' by the Node.js docs | |||
format: 'pem' | |||
}, | |||
privateKeyEncoding: { | |||
type: 'pkcs8', // recommended to be 'pkcs8' by the Node.js docs | |||
format: 'pem', | |||
cipher: 'aes-256-cbc', // *optional* | |||
passphrase: 'top secret' // *optional* | |||
} | |||
});</syntaxhighlight> | });</syntaxhighlight> | ||