aboutsummaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-11-11 00:21:00 -0800
committerfriendica <info@friendica.com>2013-11-11 00:21:00 -0800
commit435e2dae0e9204afd7288c14748e88f680276969 (patch)
tree23b1cbdbd8f2bc42ffc2243a0be95797b63b8ce5 /js
parent0adf31eef240c8d58ba6fc471892189a69d0696b (diff)
downloadvolse-hubzilla-435e2dae0e9204afd7288c14748e88f680276969.tar.gz
volse-hubzilla-435e2dae0e9204afd7288c14748e88f680276969.tar.bz2
volse-hubzilla-435e2dae0e9204afd7288c14748e88f680276969.zip
display encrypted text inline
Diffstat (limited to 'js')
-rw-r--r--js/crypto.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/js/crypto.js b/js/crypto.js
index bed1525cd..6970229ce 100644
--- a/js/crypto.js
+++ b/js/crypto.js
@@ -33,14 +33,23 @@ function red_encrypt(alg, elem,text) {
var text = $(elem).val();
+ // key and hint need to be localised
+
var enc_key = prompt('key');
+ // If you don't provide a key you get rot13, which doesn't need a key
+ // but consequently isn't secure.
+
if(! enc_key)
alg = 'rot13';
if((alg == 'rot13') || (alg == 'triple-rot13'))
newdiv = "[crypt alg='rot13']" + str_rot13(text) + '[/crypt]';
else if(alg == 'aes256') {
+
+ // This is the prompt we're going to use when the receiver tries to open it.
+ // Maybe "Grandma's maiden name" or "our secret place" or something.
+
var enc_hint = prompt('hint');
enc_text = CryptoJS.AES.encrypt(text,enc_key);
@@ -66,7 +75,7 @@ function red_encrypt(alg, elem,text) {
// }
}
-function red_decrypt(alg,hint,text) {
+function red_decrypt(alg,hint,text,elem) {
var enc_text = '';
@@ -78,8 +87,13 @@ function red_decrypt(alg,hint,text) {
enc_text = CryptoJS.AES.decrypt(text,enc_key);
}
- alert(enc_text.toString(CryptoJS.enc.Utf8));
+ // Not sure whether to drop this back in the conversation display.
+ // It probably needs a lightbox or popup window because any conversation
+ // updates could
+ // wipe out the text and make you re-enter the key if it was in the
+ // conversation. For now we do that so you can read it.
+ $(elem).html(b2h(enc_text.toString(CryptoJS.enc.Utf8)));
}