日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長(zhǎng)提供免費(fèi)收錄網(wǎng)站服務(wù),提交前請(qǐng)做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點(diǎn)擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會(huì)員:747

1.js中對(duì)字符串進(jìn)行base64編碼和解碼

function Base64() {
 // private property
 _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
 // public method for encoding
 this.encode = function (input) {
 var output = "";
 var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
 var i = 0;
 input = _utf8_encode(input);
 while (i < input.length) {
 chr1 = input.charCodeAt(i++);
 chr2 = input.charCodeAt(i++);
 chr3 = input.charCodeAt(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 +
 _keyStr.charAt(enc1) + _keyStr.charAt(enc2) +
 _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
 }
 return output;
 }
 // public method for decoding
 this.decode = function (input) {
 var output = "";
 var chr1, chr2, chr3;
 var enc1, enc2, enc3, enc4;
 var i = 0;
 input = input.replace(/[^A-Za-z0-9+/=]/g, "");
 while (i < input.length) {
 enc1 = _keyStr.indexOf(input.charAt(i++));
 enc2 = _keyStr.indexOf(input.charAt(i++));
 enc3 = _keyStr.indexOf(input.charAt(i++));
 enc4 = _keyStr.indexOf(input.charAt(i++));
 chr1 = (enc1 << 2) | (enc2 >> 4);
 chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
 chr3 = ((enc3 & 3) << 6) | enc4;
 output = output + String.fromCharCode(chr1);
 if (enc3 != 64) {
 output = output + String.fromCharCode(chr2);
 }
 if (enc4 != 64) {
 output = output + String.fromCharCode(chr3);
 }
 }
 output = _utf8_decode(output);
 return output;
 }
 // private method for UTF-8 encoding
 _utf8_encode = function (string) {
 string = string.replace(/rn/g,"n");
 var utftext = "";
 for (var n = 0; n < string.length; n++) {
 var c = string.charCodeAt(n);
 if (c < 128) {
 utftext += String.fromCharCode(c);
 } else if((c > 127) && (c < 2048)) {
 utftext += String.fromCharCode((c >> 6) | 192);
 utftext += String.fromCharCode((c & 63) | 128);
 } else {
 utftext += String.fromCharCode((c >> 12) | 224);
 utftext += String.fromCharCode(((c >> 6) & 63) | 128);
 utftext += String.fromCharCode((c & 63) | 128);
 }
 }
 return utftext;
 }
 // private method for UTF-8 decoding
 _utf8_decode = function (utftext) {
 var string = "";
 var i = 0;
 var c = c1 = c2 = 0;
 while ( i < utftext.length ) {
 c = utftext.charCodeAt(i);
 if (c < 128) {
 string += String.fromCharCode(c);
 i++;
 } else if((c > 191) && (c < 224)) {
 c2 = utftext.charCodeAt(i+1);
 string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
 i += 2;
 } else {
 c2 = utftext.charCodeAt(i+1);
 c3 = utftext.charCodeAt(i+2);
 string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
 i += 3;
 }
 }
 return string;
 }
}

2.html頁(yè)面,下面看具體代碼實(shí)現(xiàn):

<html>
<head>
 <meta charset="utf-8"/>
 <title>base64加密</title>
 <script type="text/JAVAscript" src="/MavenTest/js/base64.js"></script>
 <script type="text/JavaScript">
 var b = new Base64();
 var str1 = b.encode("admin");
 console.log("base64 encode"+str1);
 var str2 = b.encode("guangzhou");
 console.log("base64 encode"+str2);
	//解密
	//str = b.decode(str);
	//console.log("base64 decode"+str);
 function buttonFuc() {
 var condition="name="+str1+"&address="+str2;
 window.location.href="/MavenTest/testpage/base64test?"+condition;
 };
 </script>
</head>
<button οnclick="buttonFuc()">click me will format into new html</button>
<body>
</body>
</html>

分享到:
標(biāo)簽:js
用戶無(wú)頭像

網(wǎng)友整理

注冊(cè)時(shí)間:

網(wǎng)站:5 個(gè)   小程序:0 個(gè)  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會(huì)員

趕快注冊(cè)賬號(hào),推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨(dú)大挑戰(zhàn)2018-06-03

數(shù)獨(dú)一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過(guò)答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫(kù),初中,高中,大學(xué)四六

運(yùn)動(dòng)步數(shù)有氧達(dá)人2018-06-03

記錄運(yùn)動(dòng)步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績(jī)?cè)u(píng)定2018-06-03

通用課目體育訓(xùn)練成績(jī)?cè)u(píng)定