aboutsummaryrefslogtreecommitdiffstats
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
parentc39200429046cdde16edbcb6e28c5cf3c7434d4a (diff)
downloadvolse-hubzilla-ca4103debef7ecf36d93842750667e70c2a1e42a.tar.gz
volse-hubzilla-ca4103debef7ecf36d93842750667e70c2a1e42a.tar.bz2
volse-hubzilla-ca4103debef7ecf36d93842750667e70c2a1e42a.zip
e2ee
-rw-r--r--include/conversation.php2
-rw-r--r--include/features.php1
-rw-r--r--js/crypto.js40
-rw-r--r--view/php/theme_init.php1
-rw-r--r--view/theme/redbasic/css/style.css5
-rwxr-xr-xview/tpl/jot.tpl6
6 files changed, 35 insertions, 20 deletions
diff --git a/include/conversation.php b/include/conversation.php
index fc0ae98e6..88156ae63 100644
--- a/include/conversation.php
+++ b/include/conversation.php
@@ -1134,6 +1134,8 @@ function status_editor($a,$x,$popup=false) {
'$defexpire' => '',
'$feature_expire' => ((feature_enabled($x['profile_uid'],'content_expire') && (! $webpage)) ? 'block' : 'none'),
'$expires' => t('Set expiration date'),
+ '$feature_encrypt' => ((feature_enabled($x['profile_uid'],'content_encrypt') && (! $webpage)) ? 'block' : 'none'),
+ '$encrypt' => t('Encrypt text'),
));
diff --git a/include/features.php b/include/features.php
index bf3323b56..7146122b7 100644
--- a/include/features.php
+++ b/include/features.php
@@ -36,6 +36,7 @@ function get_features() {
array('richtext', t('Richtext Editor'), t('Enable richtext editor')),
array('preview', t('Post Preview'), t('Allow previewing posts and comments before publishing them')),
array('channel_sources', t('Channel Sources'), t('Automatically import channel content from other channels or feeds')),
+ array('content_encrypt', t('Encrypt Content'), t('Allow encryption of content end-to-end with a shared secret key')),
),
// Network Tools
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));
}
diff --git a/view/php/theme_init.php b/view/php/theme_init.php
index 0cb5d4d68..ab28180f2 100644
--- a/view/php/theme_init.php
+++ b/view/php/theme_init.php
@@ -25,6 +25,7 @@ head_add_js('library/jquery_ac/friendica.complete.js');
head_add_js('library/tiptip/jquery.tipTip.minified.js');
head_add_js('library/jgrowl/jquery.jgrowl_minimized.js');
head_add_js('library/tinymce/jscripts/tiny_mce/tiny_mce_src.js');
+head_add_js('library/cryptojs/components/core-min.js');
head_add_js('library/cryptojs/rollups/aes.js');
head_add_js('js/acl.js');
head_add_js('js/webtoolkit.base64.js');
diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css
index c75672202..9190e8a95 100644
--- a/view/theme/redbasic/css/style.css
+++ b/view/theme/redbasic/css/style.css
@@ -321,6 +321,7 @@ footer {
#profile-link,
#profile-title,
#profile-expires,
+#profile-encrypt,
#wall-image-upload,
#wall-file-upload,
#profile-upload-wrapper,
@@ -1142,6 +1143,10 @@ footer {
float: left;
margin-left: 15px;
}
+#profile-encrypt-wrapper {
+ float: left;
+ margin-left: 15px;
+}
#jot-preview-link {
float: left;
margin-left: 45px;
diff --git a/view/tpl/jot.tpl b/view/tpl/jot.tpl
index c04880cf7..0618e7491 100755
--- a/view/tpl/jot.tpl
+++ b/view/tpl/jot.tpl
@@ -54,9 +54,9 @@
<div id="profile-expire-wrapper" style="display: {{$feature_expire}};" >
<i id="profile-expires" class="icon-eraser jot-icons" title="{{$expires}}" onclick="jotGetExpiry();return false;"></i>
</div>
- <!-- div id="profile-encrypt-wrapper" style="display: {{$feature_encrypt}};" >
- <i id="profile-encrypt" class="icon-key jot-icons" title="{{$encrypt}}" onclick="red_encrypt('aes256','profile-jot-text',$('#profile-jot-text').val());return false;"></i>
- </div -->
+ <div id="profile-encrypt-wrapper" style="display: {{$feature_encrypt}};" >
+ <i id="profile-encrypt" class="icon-key jot-icons" title="{{$encrypt}}" onclick="red_encrypt('aes256','#profile-jot-text',$('#profile-jot-text').val());return false;"></i>
+ </div>
<div id="profile-rotator-wrapper" style="display: {{$visitor}};" >