ROT13 //JavaScript Function
Join the DZone community and get the full member experience.
Join For Free
[UPDATED CODE AND HELP CAN BE FOUND HERE]
This function codes/decodes strings into ROT13 (rotate the alpha chars by 13 positions...)
//+ Jonas Raoni Soares Silva
//@ http://jsfromhell.com/string/rot13 [v1.0]
String.prototype.rot13 = function(){ //v1.0
return this.replace(/[a-zA-Z]/g, function(c){
return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
});
};
Opinions expressed by DZone contributors are their own.
Trending
-
The Role of Automation in Streamlining DevOps Processes
-
New ORM Framework for Kotlin
-
Hiding Data in Cassandra
-
Grow Your Skills With Low-Code Automation Tools
Comments