const crypto = require('crypto'); const fs = require('fs'); let keyPair = crypto.generateKeyPairSync('rsa', { modulusLength: 4096 }); fs.writeFileSync('../keypair/private.pem', keyPair.privateKey.export({ type: 'pkcs8', format: 'pem' })); fs.writeFileSync('../keypair/public.pem', keyPair.publicKey.export({ type: 'spki', format: 'pem' }));