Created
September 25, 2015 16:59
-
-
Save tomkel/d5ea6f2e9d4c29df93e5 to your computer and use it in GitHub Desktop.
This file contains 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
function rot13(message) { | |
return message.replace(/[A-Za-z]/g, function(input){ | |
var charCode = input.charCodeAt(0); | |
var start = charCode <= 'Z' ? 65 : 97; | |
charCode = (charCode - start + 13) % 26 + start; | |
return String.fromCharCode(charCode); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment