Skip to content

Instantly share code, notes, and snippets.

@hengkiardo hengkiardo/rot13

Created Apr 16, 2015
Embed
What would you like to do?
Encodes and decodes strings into the ROT13 format (rotation of the 26 characters of the alphabet by 13 positions)
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
You can’t perform that action at this time.