//*** This code is copyright 2003 by Gavin Kistner, !@phrogz.net //*** It is covered under the license viewable at http://phrogz.net/JS/_ReuseLicense.txt //*** Reuse or modification is free provided you abide by the terms of that license. //*** (Including the first two lines above in your source code satisfies the conditions.) //Returns the Rot13 equivalent of a string String.prototype.rot13 = function(){ var str = this.valueOf(); var i,len,x,rot,tor; rot="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; tor=rot.split(/(.{13})/); tor=[].concat(tor[3],tor[1],tor[7],tor[5]).join('').split(''); for (i=0,str=str.split(''),len=str.length;i-1) str[i]=tor[x]; return str.join(''); }