Here you can find the source of rot13(str)
function rot13(str) { // LBH QVQ VG! var codeZ ='Z'.charCodeAt(0); var codeA ='A'.charCodeAt(0); var arrStr =[]; var strarr =[]; var codeChar;//from w ww .j a va 2s . com console.log(codeZ); console.log(codeA); for (var i = 0; i < str.length; i++){ if (str[i].charCodeAt(0) >= codeA && str[i].charCodeAt(0)){ //console.log(str[i].charCodeAt(0)); var ucode = parseInt(str[i].charCodeAt(0)); //codeChar = (ucode + 13)%(codeZ-codeA+1) + codeA; codeChar = (ucode + 13 - codeA)%(codeZ-codeA + 1) + codeA; console.log("codechar " + codeChar); } else { codeChar = str[i]; } arrStr.push(codeChar); } console.log(arrStr); console.log(strarr); for (var i = 0; i < arrStr.length; i++){ if (arrStr[i] >= codeA && arrStr[i] <= codeZ){ codeChar = String.fromCharCode(arrStr[i]); } else { codeChar = arrStr[i]; } strarr.push(codeChar); } console.log(strarr); str = strarr.join(''); console.log(str); return str; } // Change the inputs below to test rot13("SERR PBQR PNZC");
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); }); };
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)); }); }; var includeEmailLink = function () { var anchor = document.getElementById('hello'); var href = anchor.getAttribute('href'); return anchor.setAttribute('href', href.rot13()); ...
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); }); };
String.prototype.rot13 = function(s) return (s ? s : this).split('').map(function(_) if (!_.match(/[A-za-z]/)) return _; c = Math.floor(_.charCodeAt(0) / 97); k = (_.toLowerCase().charCodeAt(0) - 83) % 26 || 26; return String.fromCharCode(k + ((c == 0) ? 64 : 96)); }).join(''); ...
function rot13(str) { var arr = []; for (var i = 0; i < str.length; i++) { if (str.charCodeAt(i) < 65 || str.charCodeAt(i) > 90) { arr.push(str.charAt(i)); } else if (str.charCodeAt(i) > 77) { arr.push(String.fromCharCode(str.charCodeAt(i) - 13)); } else { arr.push(String.fromCharCode(str.charCodeAt(i) + 13)); ...