caesars cipher

Solutions on MaxInterview for caesars cipher by the best coders in the world

showing results for - "caesars cipher"
Burt
10 Apr 2016
1const rot13 = str => {
2  let decodedCipher = ''
3    // The number 65 represents A which also is the begining of our alphabets. 
4    // The number 90 represents Z which also is the end of our alphabets.
5    // Space and any other non-alpha character is less than 65(A) and greater than 90(Z).
6
7    // Split and loop over every character
8  str.split('').forEach(character => {
9    	// Get the integer or unicode for ever character which returns a number and store it in letterChar
10    const letterChar = character.charCodeAt()
11    
12      // Check if number(letterChar) is less than 65(A) or greater than 90(Z)
13      // If true, return the number(letterChar) which means, it could be a non-alpha character
14      // If false, return the number(letterChar) + 13, which means it has shifted 13 places.
15    let unicode = letterChar < 65 || letterChar > 90 ? letterChar : letterChar + 13
16
17      // unicode minus 1 is greater or equal to 90(Z)
18      // Set unicode to equal unicode minus 1, 
19      // we minus 1 cause unicode will give us the right operand instead of the left operand
20      // eg N + 13 will give us B instead of A, so,
21      // We substract the now(unicode-1) unicode from 90 to get the number left, then we add it to 65(A),
22      // Cause we start from begining after we've met the end
23    if((unicode - 1) >= 90) unicode = (((unicode - 1) - 90) + 65)
24
25    	// Convert and add every character to cipher
26    decodedCipher += String.fromCharCode(unicode)
27  })
28
29  return decodedCipher;
30}
31
32rot13("GUR DHVPX OEBJA SBK WHZCF BIRE GUR YNML QBT.");
33
34// With love @kouqhar
queries leading to this page
ceaser cipher codecaesar encryptioncipher cesar codecaesar cypher algorithmcaesar cipher codesubstitution cipher codecipher caesar codecaesar cipher numbercaesar cipher usagejulius caesar ciphercaesar cipher codesdecipher caesar cipherwhat is caesar cypherhow to do caesar ciphercaesar cipher explanationhow to determine a caesar ciphercaesar cipher isonline caesar cipherwhats a caesar cipher keycaesar cipher definitionwhat is a key of caesar cipher 3fcaesar cipher demohow caesar cipher worksbriefly define the caesar cipher representation of caesar ciphercaesar cryptographyceser cipher codecaesar cipher messagescaesar cipher in cryptographycaesar cipher pronunciationwhat type of encryption is caesar cipherdiscuss the concept of caesar cipher ceasers cypherwhat caesar ciphercaesar cipher puzzlecaesar cipher meaningcaesar cipher functionswhats the caesar ciphercaesar cipherwhat is caesar cipher in cryptographycaesar cipher siteceaser cypherwhat is the caesar ciphercaesar cipher examplecaesar cipher encodingcaesar cypher cryptiicaesar cipher keycaesar cipher diagramcaesar cipher keycreate caesar ciphercaesar cipher meaning 5ccaesar cipher codrcaesars cipherwhats the caesar cyphercaesar cipher cryptiicryptography caesar ciphercaesar cipher generatorcaesar cipher encryptionwho is caesar cipher 2f 2f caesar ciphercaesar cipher explainedcontoh caesar ciphercaesar cipher messagecaesar cipher decypherceaser cypher cryptiioriginal caesar ciphercaesars codecaesar cipher what is a caesar ciphercesar cypherwhat is caesar ciphercypher caesarcaesar cipher functioncaesar cipher algorithm caesar codecaesar cipher algorithmcaesar cipher numberswho made the caesar ciphercaesar cyphercaesars cypherencryption using caesar cipherceacer cipher codecaesar cipher deciphercaesars cipher