Skip to content

Instantly share code, notes, and snippets.

@tomkel
Created September 25, 2015 16:59
Show Gist options
  • Save tomkel/d5ea6f2e9d4c29df93e5 to your computer and use it in GitHub Desktop.
Save tomkel/d5ea6f2e9d4c29df93e5 to your computer and use it in GitHub Desktop.
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