Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function encryptPublicLong(text, publicKey) {
var rsa = new jsencrypt_1["default"]();
rsa.setPublicKey(publicKey);
var key = rsa.getKey();
var ct = "";
// RSA每次加密117bytes,需要辅助方法判断字符串截取位置
// 1.获取字符串截取点
var bytes = new Array();
bytes.push(0);
var byteNo = 0;
var len = text.length;
var c;
var temp = 0;
for (var i = 0; i < len; i++) {
c = text.charCodeAt(i);
if (c >= 0x010000 && c <= 0x10FFFF) { // 特殊字符,如Ř,Ţ
byteNo += 4;
}
function decryptPrivateLong(text, privateKey) {
var rsa = new jsencrypt_1["default"]();
rsa.setPrivateKey(privateKey);
var key = rsa.getKey();
text = b64tohex(text);
var maxLength = ((key.n.bitLength() + 7) >> 3);
try {
if (text.length > maxLength) {
var ct1_1 = "";
var lt = text.match(/.{1,256}/g);
if (lt) {
lt.forEach(function (entry) {
var t1 = key.decrypt(entry);
ct1_1 += t1;
});
}
return ct1_1;
}