注:该加密解码功能只在IE浏览器中测试过,其他浏览器暂未测试,请谅解
var sdf3 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcde";
// 加密 function textEncrypt(str) { var t = ""; var a, a1, a2, a3; var b = sdf3.split(""); for (var x = 0; x < str.length; x++) { a = str.charCodeAt(x); a1 = a % 41; a = (a - a1) / 41; a2 = a % 41; a = (a - a2) / 41; a3 = a % 41; t += b[a3] + b[a2] + b[a1]; } a = "z"; for (var x = 0; x < t.length; x += 3) { if (t.charAt(x) != "A") { return t; } a += t.substr(x + 1, 2); } return a; }
// 解密
function textDecryption(str) { var a1, a2, a3, b = sdf3; var d = 0; var t, a; if (str.charAt(0) == "z") { t = new Array(Math.floor((str.length - 1) / 2)); a = t.length; for (var x = 0; x < a; x++) { d++; a2 = b.indexOf(str.charAt(d)); d++; a3 = b.indexOf(str.charAt(d)); t[x] = a2 * 41 + a3; } }else { t = new Array(Math.floor(str.length / 3)); a = t.length; for (var x = 0; x < a; x++) { a1 = b.indexOf(str.charAt(d)); d++; a2 = b.indexOf(str.charAt(d)); d++; a3 = b.indexOf(str.charAt(d)); d++; t[x] = a1 * 1681 + a2 * 41 + a3; } } a = eval("String.fromCharCode(" + t.join(',') + ")"); return a; }
// 拷贝到粘贴板 function copy(value) { var Result = value; if (Result == "") { return; } else { window.clipboardData.setData("Text", Result); window.alert('已复制成功。'); } }