aboutsummaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-11-10 23:19:44 -0800
committerfriendica <info@friendica.com>2013-11-10 23:19:44 -0800
commitca4103debef7ecf36d93842750667e70c2a1e42a (patch)
treebbc416e54992236f36c98f6b04d56d899f68829e /js
parentc39200429046cdde16edbcb6e28c5cf3c7434d4a (diff)
downloadvolse-hubzilla-ca4103debef7ecf36d93842750667e70c2a1e42a.tar.gz
volse-hubzilla-ca4103debef7ecf36d93842750667e70c2a1e42a.tar.bz2
volse-hubzilla-ca4103debef7ecf36d93842750667e70c2a1e42a.zip
e2ee
Diffstat (limited to 'js')
-rw-r--r--js/crypto.js40
1 files changed, 23 insertions, 17 deletions
diff --git a/js/crypto.js b/js/crypto.js
index 4b7baa155..bed1525cd 100644
--- a/js/crypto.js
+++ b/js/crypto.js
@@ -31,33 +31,39 @@ function red_encrypt(alg, elem,text) {
var enc_text = '';
var newdiv = '';
- if(! alg)
+ var text = $(elem).val();
+
+ var enc_key = prompt('key');
+
+ if(! enc_key)
alg = 'rot13';
if((alg == 'rot13') || (alg == 'triple-rot13'))
newdiv = "[crypt alg='rot13']" + str_rot13(text) + '[/crypt]';
else if(alg == 'aes256') {
- var enc_key = prompt('key');
var enc_hint = prompt('hint');
- enc_text = base64_encode(CryptoJS.AES.encrypt(text,key));
+ enc_text = CryptoJS.AES.encrypt(text,enc_key);
+
+ encrypted = enc_text.toString();
- newdiv = "[crypt alg='aes256' hint=' + hint + ']" + enc_text + '[/crypt]';
+ newdiv = "[crypt alg='aes256' hint='" + enc_hint + "']" + encrypted + '[/crypt]';
}
alert(newdiv);
-
- textarea = document.getElementById(elem);
- if (document.selection) {
- textarea.focus();
- selected = document.selection.createRange();
- selected.text = newdiv;
- } else if (textarea.selectionStart || textarea.selectionStart == "0") {
- var start = textarea.selectionStart;
- var end = textarea.selectionEnd;
- textarea.value = textarea.value.substring(0, start) + newdiv + textarea.value.substring(end, textarea.value.length);
- }
+ $(elem).val(newdiv);
+
+// textarea = document.getElementById(elem);
+// if (document.selection) {
+// textarea.focus();
+// selected = document.selection.createRange();
+// selected.text = newdiv;
+// } else if (textarea.selectionStart || textarea.selectionStart == "0") {
+// var start = textarea.selectionStart;
+// var end = textarea.selectionEnd;
+// textarea.value = textarea.value.substring(0, start) + newdiv + textarea.value.substring(end, textarea.value.length);
+// }
}
function red_decrypt(alg,hint,text) {
@@ -69,10 +75,10 @@ function red_decrypt(alg,hint,text) {
if(alg == 'aes256') {
var enc_key = prompt(hint);
- enc_text = CryptoJS.AES.decrypt(base64_decode(text),enc_key);
+ enc_text = CryptoJS.AES.decrypt(text,enc_key);
}
- alert(enc_text);
+ alert(enc_text.toString(CryptoJS.enc.Utf8));
}