str = Buffer.from(str).toString('base64')
return crypto.publicEncrypt({
key: Buffer.from(this.publicKey),
padding: crypto.constants.RSA_PKCS1_PADDING, // 或者使用 RSA_PKCS1_PADDING RSA_PKCS1_OAEP_PADDING
oaepHash: "sha1"
},
Buffer.from(str)
).toString('hex');
云端报:
{
"code": "ERR_OSSL_RSA_INVALID_PADDING_MODE",
"msg": "error:0408F08D:rsa routines:pkey_rsa_ctrl:invalid padding mode",
"err": {
"message": "error:0408F08D:rsa routines:pkey_rsa_ctrl:invalid padding mode",
"stack": "Error: error:0408F08D:rsa routines:pkey_rsa_ctrl:invalid padding mode\n at Object.publicEncrypt (internal/crypto/cipher.js:63:12)\n at baofu.getPubSign (/var/user/util/pubFunction.js:608:17)\n at baofu.preBindingCard (/var/user/util/pubFunction.js:320:26)\n at Object.main (/var/user/service/user/pub/test/baofu.js:25:17)\n at Object.serviceRun (/var/user/@common_modules/vk-unicloud/index.js:1:12179)\n at VK.main [as router] (/var/user/@common_modules/vk-unicloud/index.js:1:17975)\n at processTicksAndRejections (internal/process/task_queues.js:97:5)\n at async Object.exports.main (/var/user/__index.js:6:9)\n at async $e (/var/user/index.js:1:85076)\n at async je (/var/user/index.js:1:86163)",
"code": "ERR_OSSL_RSA_INVALID_PADDING_MODE"
},
"requestId": "9bbc45ab-4c1d-11ef-9e42-5254005b8fc6"
}
x***@88.com (作者)
我没有使用支付宝
我使用的是阿里云 Nodejs12 和 腾讯云Nodejs12.16
2024-07-29 11:53
1***@qq.com
回复 x***@88.com: 请问博主解决了吗,我也遇到这个问题了
2024-08-21 00:33
DCloud_uniCloud_CRL
回复 1***@qq.com: 你什么问题啊
2024-08-21 10:58