admin 管理员组文章数量: 887021
2023年12月23日发(作者:json ajax教程)
base64加密解密JS脚本//密钥var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/=";//加密函数function encode64(input){ input = strUnicode2Ansi(input);
var output = ""; var chr1, chr2, chr3 = ""; var enc1, enc2, enc3, enc4 = ""; var i = 0;
do{ chr1 = deAt(i++); chr2 = deAt(i++); chr3 = deAt(i++); enc1 = chr1 >> 2; enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); enc4 = chr3 & 63; if (isNaN(chr2)) { enc3 = enc4 = 64; } else if(isNaN(chr3)) { enc4 = 64; } output = output +
(enc1) +
(enc2) +
(enc3) +
(enc4); chr1 = chr2 = chr3 = ""; enc1 = enc2 = enc3 = enc4 = "";
}while(i < ); return output;}//解密函数function decode64(input){ var output = ""; var chr1, chr2, chr3 = ""; var enc1, enc2, enc3, enc4 = ""; var i = 0;
if(%4!=0) { return ""; } var base64test = /[^A-Za-z0-9+=]/g; if ((input)) { return ""; } do { enc1 = f((i++)); enc2 = f((i++)); enc3 = f((i++)); enc4 = f((i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4;
output = output + arCode(chr1); if (enc3 != 64) { output+=arCode(chr2); } if (enc4 != 64) { output+=arCode(chr3); } chr1 = chr2 = chr3 = ""; enc1 = enc2 = enc3 = enc4 = ""; } while (i < ); return strAnsi2Unicode(output);}function UnicodeChr(){ return'00A4,00A7,00A8,00B0,00B1,00B7,00D7,00E0,00E1,00E8,00E9,00EA,00EC,00ED,00F2,00F3,00F7,00F9,00FA,00FC,0101,0113,011B,012B,014D,016B,01CE,01D0,01D2,01D4,01D6,01D8,01DA,0}function AnsicodeChr(){ return
'A1E8,A1EC,A1A7,A1E3,A1C0,A1A4,A1C1,A8A4,A8A2,A8A8,A8A6,A8BA,A8AC,A8AA,A8B0,A8AE,A1C2,A8B4,A8B2,A8B9,A8A1,A8A5,A8A7,A8A9,A8AD,A8B1,A8A3,A8AB,A8AF,A8B3,A}function UnicodeToAnsi(chrCode){ var chrHex=ng(16); chrHex="000"+rCase(); chrHex=(-4); var i=UnicodeChr().indexOf(chrHex); if(i!=-1) { chrHex=AnsicodeChr().substr(i,4); } return parseInt(chrHex,16)}function AnsiToUnicode(chrCode){ var chrHex=ng(16); chrHex="000"+rCase(); chrHex=(-4); var i=AnsicodeChr().indexOf(chrHex); if(i!=-1) { chrHex=UnicodeChr().substr(i,4); } return parseInt(chrHex,16)}function strUnicode2Ansi(asContents){ var len1=; var temp=""; for(var i=0;i
版权声明:本文标题:base64加密解密JS脚本 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1703302309h446096.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论