Archived
1
0
This repository has been archived on 2020-12-10. You can view files and clone it, but cannot push or open issues or pull requests.
old/application/views/tools/dp_encrypter_end.php

62 lines
1.9 KiB
PHP
Raw Normal View History

2018-10-16 16:28:42 +00:00
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<script type="text/javascript">
$("textarea").keyup(function () {
caesar();
});
$("input").keyup(function () {
caesar();
});
$("input").change(function () {
caesar();
});
$(window).keydown(function (a) {
if (a.keyCode == 13) {
a.preventDefault();
return false
}
});
var caesar = function () {
var f = $('#text-input').val();
var d = $('#shift-key').val();
if (d == "") {
d = 0
} else {
d = parseInt(d) % 26
}
var e = "";
if ($('#decrypt').is(":checked")) {
d *= -1;
}
console.log(d);
for (var c = 0; c < f.length; c++) {
var a = f.charCodeAt(c);
if (a >= 97 && a <= 122) {
e += String.fromCharCode(((a - 97 + d + 26) % 26) + 97)
} else {
if (a >= 65 && a <= 90) {
e += String.fromCharCode(((a - 65 + d + 26) % 26) + 65)
} else {
e += String.fromCharCode(a)
}
}
}
$('#text-output').val(e);
};
$('#encrypt').change(function() {
$('#text-input-label').text('<?= lang('encrypter_text') ?>');
$('#text-input').attr('placeholder', '<?= lang('encrypter_text2') ?>');
$('#text-output-label').text('<?= lang('encrypter_output') ?>');
$('#text-output').attr('placeholder', '<?= lang('encrypter_output') ?>');
});
$('#decrypt').change(function() {
$('#text-input-label').text('<?= lang('decrypter_text') ?>');
$('#text-input').attr('placeholder', '<?= lang('decrypter_text2') ?>');
$('#text-output-label').text('<?= lang('decrypter_output') ?>');
$('#text-output').attr('placeholder', '<?= lang('decrypter_output') ?>');
});
</script>