e2ee
This commit is contained in:
parent
c392004290
commit
ca4103debe
@ -1134,6 +1134,8 @@ function status_editor($a,$x,$popup=false) {
|
|||||||
'$defexpire' => '',
|
'$defexpire' => '',
|
||||||
'$feature_expire' => ((feature_enabled($x['profile_uid'],'content_expire') && (! $webpage)) ? 'block' : 'none'),
|
'$feature_expire' => ((feature_enabled($x['profile_uid'],'content_expire') && (! $webpage)) ? 'block' : 'none'),
|
||||||
'$expires' => t('Set expiration date'),
|
'$expires' => t('Set expiration date'),
|
||||||
|
'$feature_encrypt' => ((feature_enabled($x['profile_uid'],'content_encrypt') && (! $webpage)) ? 'block' : 'none'),
|
||||||
|
'$encrypt' => t('Encrypt text'),
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ function get_features() {
|
|||||||
array('richtext', t('Richtext Editor'), t('Enable richtext editor')),
|
array('richtext', t('Richtext Editor'), t('Enable richtext editor')),
|
||||||
array('preview', t('Post Preview'), t('Allow previewing posts and comments before publishing them')),
|
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('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
|
// Network Tools
|
||||||
|
38
js/crypto.js
38
js/crypto.js
@ -31,33 +31,39 @@ function red_encrypt(alg, elem,text) {
|
|||||||
var enc_text = '';
|
var enc_text = '';
|
||||||
var newdiv = '';
|
var newdiv = '';
|
||||||
|
|
||||||
if(! alg)
|
var text = $(elem).val();
|
||||||
|
|
||||||
|
var enc_key = prompt('key');
|
||||||
|
|
||||||
|
if(! enc_key)
|
||||||
alg = 'rot13';
|
alg = 'rot13';
|
||||||
|
|
||||||
if((alg == 'rot13') || (alg == 'triple-rot13'))
|
if((alg == 'rot13') || (alg == 'triple-rot13'))
|
||||||
newdiv = "[crypt alg='rot13']" + str_rot13(text) + '[/crypt]';
|
newdiv = "[crypt alg='rot13']" + str_rot13(text) + '[/crypt]';
|
||||||
else if(alg == 'aes256') {
|
else if(alg == 'aes256') {
|
||||||
var enc_key = prompt('key');
|
|
||||||
var enc_hint = prompt('hint');
|
var enc_hint = prompt('hint');
|
||||||
|
|
||||||
enc_text = base64_encode(CryptoJS.AES.encrypt(text,key));
|
enc_text = CryptoJS.AES.encrypt(text,enc_key);
|
||||||
|
|
||||||
newdiv = "[crypt alg='aes256' hint=' + hint + ']" + enc_text + '[/crypt]';
|
encrypted = enc_text.toString();
|
||||||
|
|
||||||
|
newdiv = "[crypt alg='aes256' hint='" + enc_hint + "']" + encrypted + '[/crypt]';
|
||||||
}
|
}
|
||||||
|
|
||||||
alert(newdiv);
|
alert(newdiv);
|
||||||
|
|
||||||
|
$(elem).val(newdiv);
|
||||||
|
|
||||||
textarea = document.getElementById(elem);
|
// textarea = document.getElementById(elem);
|
||||||
if (document.selection) {
|
// if (document.selection) {
|
||||||
textarea.focus();
|
// textarea.focus();
|
||||||
selected = document.selection.createRange();
|
// selected = document.selection.createRange();
|
||||||
selected.text = newdiv;
|
// selected.text = newdiv;
|
||||||
} else if (textarea.selectionStart || textarea.selectionStart == "0") {
|
// } else if (textarea.selectionStart || textarea.selectionStart == "0") {
|
||||||
var start = textarea.selectionStart;
|
// var start = textarea.selectionStart;
|
||||||
var end = textarea.selectionEnd;
|
// var end = textarea.selectionEnd;
|
||||||
textarea.value = textarea.value.substring(0, start) + newdiv + textarea.value.substring(end, textarea.value.length);
|
// textarea.value = textarea.value.substring(0, start) + newdiv + textarea.value.substring(end, textarea.value.length);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
function red_decrypt(alg,hint,text) {
|
function red_decrypt(alg,hint,text) {
|
||||||
@ -69,10 +75,10 @@ function red_decrypt(alg,hint,text) {
|
|||||||
|
|
||||||
if(alg == 'aes256') {
|
if(alg == 'aes256') {
|
||||||
var enc_key = prompt(hint);
|
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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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/tiptip/jquery.tipTip.minified.js');
|
||||||
head_add_js('library/jgrowl/jquery.jgrowl_minimized.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/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('library/cryptojs/rollups/aes.js');
|
||||||
head_add_js('js/acl.js');
|
head_add_js('js/acl.js');
|
||||||
head_add_js('js/webtoolkit.base64.js');
|
head_add_js('js/webtoolkit.base64.js');
|
||||||
|
@ -321,6 +321,7 @@ footer {
|
|||||||
#profile-link,
|
#profile-link,
|
||||||
#profile-title,
|
#profile-title,
|
||||||
#profile-expires,
|
#profile-expires,
|
||||||
|
#profile-encrypt,
|
||||||
#wall-image-upload,
|
#wall-image-upload,
|
||||||
#wall-file-upload,
|
#wall-file-upload,
|
||||||
#profile-upload-wrapper,
|
#profile-upload-wrapper,
|
||||||
@ -1142,6 +1143,10 @@ footer {
|
|||||||
float: left;
|
float: left;
|
||||||
margin-left: 15px;
|
margin-left: 15px;
|
||||||
}
|
}
|
||||||
|
#profile-encrypt-wrapper {
|
||||||
|
float: left;
|
||||||
|
margin-left: 15px;
|
||||||
|
}
|
||||||
#jot-preview-link {
|
#jot-preview-link {
|
||||||
float: left;
|
float: left;
|
||||||
margin-left: 45px;
|
margin-left: 45px;
|
||||||
|
@ -54,9 +54,9 @@
|
|||||||
<div id="profile-expire-wrapper" style="display: {{$feature_expire}};" >
|
<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>
|
<i id="profile-expires" class="icon-eraser jot-icons" title="{{$expires}}" onclick="jotGetExpiry();return false;"></i>
|
||||||
</div>
|
</div>
|
||||||
<!-- div id="profile-encrypt-wrapper" style="display: {{$feature_encrypt}};" >
|
<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>
|
<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>
|
||||||
|
|
||||||
|
|
||||||
<div id="profile-rotator-wrapper" style="display: {{$visitor}};" >
|
<div id="profile-rotator-wrapper" style="display: {{$visitor}};" >
|
||||||
|
Reference in New Issue
Block a user