日期:2014-05-16 浏览次数:20328 次
var s = 'AZaz'; function encrypt(str) { var ar = str.split(''); for (var i = 0; i < ar.length; i ++) { if (/[a-z]/i.test(ar[i])) { if (ar[i] == 'Z' || ar[i] == 'z') ar[i] = String.fromCharCode(ar[i].charCodeAt(0) - 25); else ar[i] = String.fromCharCode(ar[i].charCodeAt(0) + 1); } } return ar.join(''); } alert(encrypt(s)); //BAba