From b2c7ce8546c75a62e6ef72f8e99136f7e0277c73 Mon Sep 17 00:00:00 2001 From: "Vyacheslav N. Boyko" Date: Fri, 28 Dec 2018 23:48:56 +0300 Subject: [PATCH] working on --- .gitignore | 5 ++++- lor-cryptomsg.js | 45 +++++++++++++++++++++------------------------ 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.gitignore b/.gitignore index 42dd357..fc8ab39 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,4 @@ -/*~ \ No newline at end of file +/*~ +*.iml +*.ipr +*.iws \ No newline at end of file diff --git a/lor-cryptomsg.js b/lor-cryptomsg.js index 0873797..9715692 100644 --- a/lor-cryptomsg.js +++ b/lor-cryptomsg.js @@ -86,35 +86,32 @@ uku7JUXcVpt08DFSceCEX9unCuMcT72rAQlLpdZir876 var author = $(messageTag).find('.sign a[itemprop="creator"]').text(); if (msg && msg.length && author.trim() != '') { - var encryptedRegexp = /(\[ENCRYPTED\][\s\S]+\[\/ENCRYPTED\])+?/mi; - var encryptedMsgRegexp = /\[ENCRYPTED\]([\s\S]+)\[\/ENCRYPTED\]/mi; + var encryptedRegexp = /\[ENCRYPTED\]([\s\S]+)\[\/ENCRYPTED\]/mi; + var encryptedRegexpMy = /\[ENCORIGIN\]([\s\S]+)\[\/ENCORIGIN\]/mi; + var regexp; Array.prototype.forEach.call(msg, function(p) { var msg = p.innerText; - if (msg.trim() != '' && encryptedRegexp.test(msg)) { - - var result = msg.match(encryptedRegexp); - if (result && result.length >= 1) { - - for (var i=1; i= 1) { + var encMsg = result[1]; + var decrypt = new JSEncrypt.JSEncrypt(); + decrypt.setPrivateKey(privateKey); + var decryptedMsg = decrypt.decrypt(encMsg); + if (i == 0) { + msg = msg.replace(encBlock, '[DECRYPTED]'+decryptedMsg+'[/DECRYTED]'); + } else { + msg = msg.replace(encBlock, '[ORIGIN]'+decryptedMsg+'[/ORIGIN]'); } } - } - } p.innerText = msg; }); @@ -157,7 +154,7 @@ uku7JUXcVpt08DFSceCEX9unCuMcT72rAQlLpdZir876 var encryptedMsg = encrypt.encrypt(msg); var encryptedMsgMy = encryptMy.encrypt(msg); - insertText(textarea, '[ENCRYPTED]' + encryptedMsg + '[/ENCRYPTED]' + '[ENCRYPTED]' + encryptedMsgMy + '[/ENCRYPTED]'); + insertText(textarea, '[ENCRYPTED]' + encryptedMsg + '[/ENCRYPTED]' + '[ENCORIGIN]' + encryptedMsgMy + '[/ENCORIGIN]'); });