底下這段是針對RSA在JS長字串處理
對映至 java 是否有相映的方法?
JSEncrypt.prototype.encryptLong = function (text) {
let k = this.getKey();
let maxLength = (((k.n.bitLength() + 7) >> 3) - 11);
try {
if (text.length > maxLength) {
let lt = text.match(/.{1,117}/g), ct = '';
lt.forEach((entry) => { ct += k.encrypt(entry); });
return ct;
}
return k.encrypt(text);
} catch (ex) {
console.warn('encryptLong error:', ex);
return false;
}
}
// 长文本解密处理
JSEncrypt.prototype.decryptLong = function (text) {
let k = this.getKey();
let maxLength = ((k.n.bitLength() + 7) >> 3);
try {
if (text.length > maxLength) {
let lt = text.match(/.{1,256}/g), ct = '';
lt.forEach((entry) => { ct += k.decrypt(entry); });
return ct;
}
return k.decrypt(text);
} catch (ex) {
console.warn('decryptLong error:', ex);
return false;
}
}