caesar cipher javascript

Solutions on MaxInterview for caesar cipher javascript by the best coders in the world

showing results for - "caesar cipher javascript"
Mira
31 Jan 2021
1function rot13(str) {
2var charcode = [];
3var words = [];
4
5for(let i = 0; i < str.length; i++){
6  
7  var asc = str.charCodeAt(i)
8  
9  charcode.push(asc)
10}
11var converted = charcode.map(function(a){
12  return a-13
13})
14console.log(converted)
15converted.forEach((letter)=>{
16 if(letter >= 65){
17  var final =String.fromCharCode(letter)
18  words.push(final)
19 }
20 else if(letter>=52){
21   final = String.fromCharCode(letter+26)
22   words.push(final)
23 }
24 else {
25   final = String.fromCharCode(letter+13)
26   words.push(final)
27 }
28 
29})
30return words.join("")
31}
32
33console.log(rot13("SERR YBIR?"));
Melina
28 Feb 2018
1   var myCipher = [];
2      var myArray = []; 
3      
4      for (i=0; i < str.length; i++) {
5        // convert character - or don't if it's a punctuation mark.  Ignore spaces.
6        if (str.charCodeAt(i) > 64 && str.charCodeAt(i) < 78) {
7             myArray.push(String.fromCharCode(str.charCodeAt(i) + 13));
8         } else if (str.charCodeAt(i) > 77 && str.charCodeAt(i) < 91) { 
9             myArray.push(String.fromCharCode(77 - (90 - str.charCodeAt(i))));
10         } else if (str.charCodeAt(i) > 32 && str.charCodeAt(i) < 65) {
11             myArray.push(str.charAt(i));
12         }
13       
14        // push word onto array when encountering a space or reaching the end of the string
15        
16        if (str.charCodeAt(i) == 32) {
17          myCipher.push(myArray.join(''));
18          myArray.length = 0;      
19        }
20        
21        if (i == (str.length - 1)) {
22           myCipher.push(myArray.join(''));
23        }
24
25      }
26
27      return myCipher.join(" ");
28      
29    }
queries leading to this page
caesar cipher encryption and decryption in javascriptcaesars cypher javascript with casecaesar cipher javascript code solutionjavascript ceasers ciphersimple javascript caesar ciphercaesar cipher jsjs caesar shift codecaesar cipher en jsjavascript how to write a caesar cipher step by stepcaesar cipher code in javascripthow do dechipher ceasar cipher jscaesar 27s cypher that checks upper and lowercase letters jscaesar chipher jscaesar cipher encryption javascriptatbash cipher javascript algorithmcaesar cipher javascript casescaesar cypher using javascriptjavascript caesar cipher examplesjavascript ceaser ciphercaesar javascript problemcaesar shift decoder javascriptcaesar cipher js encrypt and decrypt codecaesar cipher solver jscaesar cipher javascript logic explainedencrypting a string using caesar cipher in javascriptjs caesar cipherhow to create ceasar cipher javascriptcaesars cipher javascript projectceaser cipher javascriptcaesar cipher function in javascriptcaesar cipher using javascriptcaesars cipher in jscaeser cipher js caesar encryption in javascriptcaesar cipher encryption jscipher caesar in node jscipher string jscesar cipher function jscaesar cipher program in jscaesar cipher javascript case insensitiveceasars shift javascriptjavascript how to write a ceaser cipherprogram caesar cipher javascriptcaesar cipher javascriptjavascript the caesar 28 29 function in the src 2fcaesar jscipher in javascriptjs ceaser ciphercaesar cipher and password encryption 2fdecryption jscaesar code jsjavascript how to caesar cipher decodecaesar cipher javascript codeshift cipher code in javascripthow to solve cipher javascriptjs caesar cipher explainedhow to do caesar cipher javascriptcaesar shift decode javascriptcaeser cipher javascriptcaesar cipher java script caesar cipher technique in jsjavascript ciphercaesars cipher javascript algorithmcaesar cipher js codecreate a caesar cypher that encrypts a string in javascriptcaesar cipher in javascriptcaesar cipher javascript asciihow to make a cipher in javascriptcaesar cypher javascriptcaesar cipher javascript gcaesar cipher javascript keeps numberscaesar cipher encrypter code jscaesar ciphe jsjs caesar cipher functioncipher string in jscaesar jscipher decipher javascriptcaesars cipher javascriptencode caesar javascriptcaesars cipher jsjavascript how to write a ceaser cipher step by stepa caesar cypher with a function in javascriptcaesar cipher algorithm javascriptcaesar encoding javascripthow to code a caesar cipher in javascriptjavascript caesar cipherceasar cipher javascriptcaesar shift javascriptjavascript cipher stringcesar encryption in javascriptcaesar function jscaesar cipher node jsjs cesar encryptionceasars cipher jshow to make a caesar cipher in javascriptcaesar cypher jsjs caesar cipher numberscesar cipher jscaesar cipher technique in jscaesar cipher javascript caesar cipher javascript