Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="pl">
- <head>
- <title>szyfr cezara</title>
- <meta charset="utf-8" />
- </head>
- <body>
- <textarea id="message" rows="5" cols="40" ></textarea><br />
- <button id="encode">Szyfruj</button> <button id="decode">Odszyfruj</button><br />
- <textarea id="cipher" rows="5" cols="40"></textarea>
- <script>
- document.getElementById('encode').addEventListener('click',function(){
- var message = document.getElementById('message').value;
- var cipher = document.getElementById('cipher');
- cipher.value = ' ';
- for(var i=0; i < message.length; i++)
- cipher.value += String.fromCharCode(message.charCodeAt(i)+3)
- });
- document.getElementById('decode').addEventListener('click',function(){
- var cipher = document.getElementById('cipher').value;
- var message = document.getElementById('message');
- message.value = ' ';
- for(var i=0; i < cipher.length; i++)
- message.value += String.fromCharCode(cipher.charCodeAt(i)-3)
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement