const fs=require('fs');const crypto=require('crypto');const privateKey=fs.readFileSync('8000013189_pri.pem','utf-8');console.log(privateKey);function encrypt(stuff) {let encryptString = Buffer.from(Buffer.from(stuff).toString('base64'));let result ='';while (encryptString.length > 117) {const chunk = encryptString.slice(0, 117);encryptString = encryptString.slice(117);result += crypto.privateEncrypt(privateKey, chunk).toString('hex');}result += crypto.privateEncrypt(privateKey, encryptString).toString('hex');return result;}console.log(encrypt("123456"));
文档更新时间: 2019-06-17 11:21 作者:support