Created
July 26, 2017 12:36
-
-
Save dmjcomdem/1a2fc5c8772c4c93447c0d50acb8b4d6 to your computer and use it in GitHub Desktop.
Простой способ Ceasars Cipher Encryptor (сдвиг позиции буквы в алфавите )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toLowerCase(), | |
otherCharacters = '-=~\"\'#$%&*^:<>?/!{(|)}.1234567890\, '; | |
var shiftedAlphabet = alphabet.slice(3); | |
shiftedAlphabet += alphabet.slice(0, 3); | |
shiftedAlphabet += otherCharacters; | |
alphabet += otherCharacters; | |
var str = 'I am amazing'.toLowerCase(), | |
out = ''; | |
for(var i = 0; i < str.length; i++){ | |
var numberd = alphabet.indexOf( str[i] ) | |
out += shiftedAlphabet[numberd]; | |
} | |
console.log(out) // I am amazing => l dp dpdclqj |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment