Nuestro team redactor ha estado largas horas investigando para dar espuestas a tus interrogantes, te regalamos la solución de modo que esperamos que te resulte de gran apoyo.
Ejemplo: cifrado RSA, JavaScript
<script type="text/javascript">$(function()//Change the key size value for new keys$(".change-key-size").each(function(index, value)var el =$(value);var keySize = el.attr('data-value');
el.click(function(e)var button =$('#key-size');
button.attr('data-value', keySize);
button.html(keySize +' bit ');
e.preventDefault();););// Execute when they click the button.$('#execute').click(function()// Create the encryption object.var crypt =newJSEncrypt();// Set the private.
crypt.setPrivateKey($('#privkey').val());//return;// If no public key is set then set it here...var pubkey =$('#pubkey').val();if(!pubkey)$('#pubkey').val(crypt.getPublicKey());// Get the input and crypted values.var input =$('#input').val();var crypted =$('#crypted').val();// Alternate the values.if(input)$('#crypted').val(crypt.encrypt(input));$('#input').val('');elseif(crypted)var decrypted = crypt.decrypt(crypted);if(!decrypted)
decrypted ='This is a test!';$('#input').val(decrypted);$('#crypted').val(''););vargenerateKeys=function()var sKeySize =$('#key-size').attr('data-value');var keySize =parseInt(sKeySize);var crypt =newJSEncrypt( default_key_size: keySize );var async =$('#async-ck').is(':checked');var dt =newDate();var time =-(dt.getTime());if(async)$('#time-report').text('.');var load =setInterval(function()var text =$('#time-report').text();$('#time-report').text(text +'.');,500);
crypt.getKey(function()clearInterval(load);
dt =newDate();
time +=(dt.getTime());$('#time-report').text('Generated in '+ time +' ms');$('#privkey').val(crypt.getPrivateKey());$('#pubkey').val(crypt.getPublicKey()););return;
crypt.getKey();
dt =newDate();
time +=(dt.getTime());$('#time-report').text('Generated in '+ time +' ms');$('#privkey').val(crypt.getPrivateKey());$('#pubkey').val(crypt.getPublicKey());;// If they wish to generate new keys.$('#generate').click(generateKeys);generateKeys(););</script>
Si para ti ha sido útil nuestro post, nos gustaría que lo compartas con otros juniors de este modo nos ayudas a difundir nuestro contenido.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)