<div class="codetitle"> <span><a style="CURSOR: pointer" data="14136" class="copybut" id="copybut14136" onclick="doCopy('code14136')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code14136"> <br><script type="text/javascript"> <br><br> <BR><script type="text/javascript"> <><BR><BR>var base64encodechars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 /"; <BR>var base64decodechars = new Array( <BR>-1, -11 , -1, -1, -1, -1, -1, -1, <BR>-1, -1, -1, -1, -1, -1, -1, -1, -1, - 1, -1, -1, -1, -1, -1, -1, <BR>-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, <BR>52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1 , -1, -1, -1, <BR>-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, <br>15 , 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, <br>-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, <BR>41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, - -1, -1, -1, -1); <BR><BR>function base64encode(str) { <BR>var out, i, len; <BR>var c1, c2, c3; <BR>len = str.length; <BR>i = 0; <BR>out = ""; <BR>while (i < len) { <BR>c1 = str.charCodeAt(i ) & 0xff; <BR>if (i = = len) { <BR>out = base64encodechars.charAt(c1 >> 2); <BR>out = base64encodechars.charAt((c1 & 0x3) << 4); <BR>out = "=="; <BR>break; <BR>} <BR>c2 = str.charCodeAt(i ); <BR>if (i == len) { <BR>out = base64encodechars.charAt(c1 >> 2); <BR>out = base64encodechars.charAt(((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4)); <BR>out = base64encodechars.charAt((c2 & 0xf) << 2); <BR>out <BR>out = "="; <BR>break; <BR>} <BR>c3 = str.charCodeAt(i ); <BR>out = base64encodechars.charAt(c1 >> 2); <BR>out = base64encodechars.charAt( ((c1 & 0x3) << 4) | ((c2 & 0xf0) >> 4)); <BR>out = base64encodechars.charAt(((c2 & 0xf) << 2) | ((c3 & 0xc0) > > 6)); <br>out = base64encodechars.charAt(c3 & 0x3f); <br>} <BR>return out; <BR>} <br><br>function base64decode(str) { <1🎜><br>function base64decode(str) { , c2, c3, c4; <br>var i, len, out; <BR><BR>len = str.length; <br><br>i = 0; <BR>out = ""; <BR> while (i < len) { <BR><BR>do { <br>c1 = base64decodechars[str.charCodeAt(i ) & 0xff]; <br>} while (i < len && c1 == -1); <BR>if (c1 == -1) <BR>break; <BR><BR>do { <br>c2 = base64decodechars[str.charCodeAt(i ) & 0xff]; <br>} while (i < len && c2 == -1); <br>if (c2 == -1) <br>break; <BR><BR>out = String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4)); <BR><BR>do { <BR>c3 = str.charCodeAt(i ) & 0xff; <BR>if (c3 == 61) <BR>return out; <br>c3 = base64decodechars[basec3 ]; <br>} while (i < len && c3 == -1); <br>if (c3 == -1) <br>break; <BR><BR>out = String.fromCharCode(((c2 & 0xf) << 4) | ((c3 & 0x3c) >> 2)); <BR><BR>do { <BR>c4 = str.charCodeAt(i ) & 0xff; <BR>if (c4 == 61) <BR>return out; <BR>c4 = base64decodechars[c4]; <BR>} while (i < len && c4 == -1); <BR>if (c4 == -1) <BR>break -1); <BR>if (c4 == -1) <BR>break ; </script> </div>out = String.fromCharCode(((c3 & 0x03) } return out; }