Advertisement
Guest User

Untitled

a guest
Nov 20th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="pl">
  3. <head>
  4. <title>szyfr cezara</title>
  5. <meta charset="utf-8" />
  6. </head>
  7. <body>
  8. <textarea id="message" rows="5" cols="40" ></textarea><br />
  9. <button id="encode">Szyfruj</button> <button id="decode">Odszyfruj</button><br />
  10. <textarea id="cipher" rows="5" cols="40"></textarea>
  11.  
  12.  
  13.  
  14. <script>
  15. document.getElementById('encode').addEventListener('click',function(){
  16. var message = document.getElementById('message').value;
  17. var cipher = document.getElementById('cipher');
  18. cipher.value = ' ';
  19. for(var i=0; i < message.length; i++)
  20. cipher.value += String.fromCharCode(message.charCodeAt(i)+3)
  21.  
  22. });
  23. document.getElementById('decode').addEventListener('click',function(){
  24. var cipher = document.getElementById('cipher').value;
  25. var message = document.getElementById('message');
  26. message.value = ' ';
  27. for(var i=0; i < cipher.length; i++)
  28. message.value += String.fromCharCode(cipher.charCodeAt(i)-3)
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. });
  40. </script>
  41. </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement