Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var cipherResult = document.getElementById('cipherResult');
- var descramblerResult = document.getElementById('descramblerResult');
- function rot4(str)
- {
- var first = document.getElementById('first').value;
- var str = first;
- console.log(str);
- var num = document.getElementById('number').value;
- var ilee = parseInt(num,10);
- zdanie = "";
- for (var i = 0; i < str.length ; i++)
- {
- console.log(ilee);
- //var zmienna = prompt("Wprowadz tutaj wartosc");
- var asciinum = str[i].charCodeAt();// Zamienia podana litere na liczbe z ASCII
- if(asciinum==32)
- {
- zdanie +=String.fromCharCode(asciinum);
- }
- else if ( (asciinum + ilee >= 97 && asciinum + ilee <= 122) || (asciinum + ilee >= 65 && asciinum + ilee <= 90))
- {
- zdanie += String.fromCharCode(asciinum + ilee); // zmienna letter przeksztalca z liczby ASCII na litere + dodaje 4
- }
- else
- {
- zdanie += String.fromCharCode(asciinum + ilee -26);
- }
- }
- return cipherResult.textContent = zdanie;
- };
- function odrot4(str)
- {
- str = this.zdanie;
- var num = document.getElementById('number').value;
- var ile = parseInt(num,10);
- ile = ile*(-1);
- var zdanie = "";
- for (var i = 0; i < str.length ; i++)
- {
- //var zmienna = prompt("Wprowadz tutaj wartosc");
- var asciinum = str[i].charCodeAt();// Zamienia podana litere na liczbe z ASCII
- if(asciinum==32)
- {
- zdanie +=String.fromCharCode(asciinum);
- }
- else if ( (asciinum + ile >= 97 && asciinum + ile <= 122) || (asciinum + ile >= 65 && asciinum + ile <= 90))
- {
- zdanie += String.fromCharCode(asciinum + ile); // zmienna letter przeksztalca z liczby ASCII na litere + dodaje 4
- }
- else
- {
- zdanie += String.fromCharCode(asciinum + ile +26);
- }
- }
- return descramblerResult.textContent = zdanie;
- };
- // var currentLetter = "e";
- // var asciiCode = currentLetter.charCodeAt();
- // var plus4 = asciiCode + 4;
- // var convertedLetter = String.fromCharCode(plus4);
- // console.log(asciiCode);
- // console.log(plus4);
- // console.log(convertedLetter);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement