1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| <textarea name="" id="key" cols="200" rows="10">-----BEGIN PUBLIC KEY----- ############################################################ ############################################################ ############################################################ ############################################################ -----END PUBLIC KEY----- </textarea>
<script src="/admin/static/jsencrypt.min.js"></script> <script type="text/javascript"> $(function () { $('#submit').click(function () { test(); }) })
function test() { let encrypt = new JSEncrypt(); let pub_key = $('#key').val(); encrypt.setPublicKey(pub_key); let data = encrypt.encrypt("123456"); let csrf = '@csrf'; csrf = $(csrf).val(); $.post('{{url("admin/~~test~~/ajax")}}', {data: encodeURI(data).replace(/\+/g, '%2B'), _token: csrf}, function (res) { console.log(res); }, 'json') } </script>
|