SOURCE

function encryptByRSA(publicKey, plainText) {
	const encryptor = new JSEncrypt();
	encryptor.setPublicKey(publicKey);
	return encryptor.encrypt(plainText);
}


function doEncrypt(inputData) {
	console.log("doencrypt -> getkey");
	let _pubKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCvwBiMlwwq68JC+jdE3Z2D8swz4HKqvJaxw3wR5majUTakNgiM3Anf2kkKMEpbTmMA5m2GQDz6ywRbhQ103g3zndfDIP35TeqgFSkOq3U94iCjIedjzBq+X6ePTEBDhKNqskhbcoM97q0BadIT1gPhJKndJ8bZRaNYHE9pka4OxwIDAQAB";
	if(_pubKey==undefined){
		_pubKey = '';
	}
	
	let objStr = JSON.stringify(inputData);
	let objStrLength = objStr.length;
	let splitLength = 80;
	//字符切断长度
	let num = parseInt(objStrLength / splitLength);
	if (objStrLength % splitLength > 0) {
		num = num + 1;
	}
	let encryptAry = [];
	for (let i = 0; i < num; i++) {
		let jmStr = "";
		if (i < (num - 1)) {
			jmStr = objStr.substr(i * splitLength, splitLength);
		} else {
			jmStr = objStr.substr(i * splitLength);
		}
		let cipherText = encryptByRSA(_pubKey, jmStr); //RAS加码
        console.log(jmStr);
		encryptAry.push(cipherText);
	}
	let joinedEncrypt = encryptAry.join("_"); //拼接加密后的字符串
	let output = {
		encrypt: joinedEncrypt
	};
	return output;
}
var inputData = {"Bsn_Scn_ID":"P100501","Enqr_TpDs":"01","Enqr_StDt":"","Enqr_CODt":"","Inf_KeyWrd":"","Rsrv_Fld_2":"","Rsrv_Fld_3":"","PAGE_JUMP":1,"REC_IN_PAGE":20}
console.log("doEncrypt ->" +  JSON.stringify(doEncrypt(inputData)));
console 命令行工具 X clear

                    
>
console