Created
April 16, 2015 06:45
-
-
Save hengkiardo/a171134eef21cda285d3 to your computer and use it in GitHub Desktop.
Encodes and decodes strings into the ROT13 format (rotation of the 26 characters of the alphabet by 13 positions)
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
String.prototype.rot13 = function(){ | |
return this.replace(/[a-zA-Z]/g, function(c){ | |
return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment