FCC:Caesars Cipher (ROT13解码)

function rot13(str) { // LBH QVQ VG!
  var arr=str.split("");	//转字符串
  var t;

  for (var i=0;i=65&&str.charCodeAt(i)<=90){
      t = str.charCodeAt(i)-13;
      if (t<65){
        t = t + 26;
      }
      arr[i] = String.fromCharCode(t);
    }
  }

  str = arr.join("");	//转回数组

  return str;
}

rot13("SERR PBQR PNZC");//输出结果:FREE CODE CAMP

你可能感兴趣的:(FCC:Caesars Cipher (ROT13解码))