我是否正确假设可以仅将base64编码的缓冲区包装在页眉和页脚中就可以将Node.js生成的ECDH密钥格式化为PEM?
const { ECDH } = require('crypto')
const ecdh = ECDH('secp256k1')
ecdh.generateKeys()
const publicKey = ecdh.getPublicKey('buffer', 'uncompressed')
const privateKey = ecdh.getPrivateKey('buffer', 'uncompressed')
const publicPem = `-----BEGIN PUBLIC KEY-----\n${publicKey.toString('base64')}\n-----END PUBLIC KEY-----\n`
const privatePem = `-----BEGIN EC PRIVATE KEY-----\n${privateKey.toString('base64')}\n-----END EC PRIVATE KEY-----\n`
console.log('==================================')
console.log(privatePem)
console.log(publicPem)
console.log('==================================')