You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suggest to add judgment when string too long
If the string is too long, it should be encrypted by dividing it into blocks.
I've seen many people react and think that this is a bug.
/**
* Encrypt long strings by segmenting them.
* @param {string} str the string to encrypt
* @return {string} the encrypted string encoded in base64
* @public
*/
encryptLong: function(str,$key) {
var encryptor = new JSEncrypt();
encryptor.setPublicKey($key);
var maxChunkLength = 100,
output = '',
inOffset = 0,
outOffset = 0;
while (inOffset < str.length) {
console.log(str.substring(inOffset, inOffset + maxChunkLength));
output += encryptor.encrypt(str.substring(inOffset, inOffset + maxChunkLength));
inOffset += maxChunkLength;
}
return output;
},
/**
* Decrypting long texts
* @param {string} string The base64 encoding of the encrypted message.
* @returns {string} Decrypted original text
*/
decryptLong: function(string,$key) {
var decryptor = new JSEncrypt();
decryptor.setPrivateKey($key);
var maxChunkLength = 172,
output = '',
inOffset = 0,
outOffset = 0;
while (inOffset < string.length) {
console.log(string.substring(inOffset, inOffset + maxChunkLength));
output += decryptor.decrypt(string.substring(inOffset, inOffset + maxChunkLength));
inOffset += maxChunkLength;
}
return output;
},
The text was updated successfully, but these errors were encountered:
Suggest to add judgment when string too long
If the string is too long, it should be encrypted by dividing it into blocks.
I've seen many people react and think that this is a bug.
The text was updated successfully, but these errors were encountered: