This commit is contained in:
friendica 2013-11-10 23:19:44 -08:00
parent c392004290
commit ca4103debe
6 changed files with 34 additions and 19 deletions

View File

@ -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'),
));

View File

@ -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

View File

@ -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);
newdiv = "[crypt alg='aes256' hint=' + hint + ']" + enc_text + '[/crypt]';
encrypted = enc_text.toString();
newdiv = "[crypt alg='aes256' hint='" + enc_hint + "']" + encrypted + '[/crypt]';
}
alert(newdiv);
$(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);
}
// 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));
}

View File

@ -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');

View File

@ -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;

View File

@ -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}};" >