//base64加密
function base64_encode(e){
var r=function(e){
return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,r){return String.fromCharCode("0x"+r)})};
if("undefined"==typeof window)return new Buffer(e).toString("base64");
if(void 0!==window.btoa)return window.btoa(r(e));
var n,t,o,i,a,c,d,f,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u=0,w=0,A="",l=[];
if(!e)return e;e=r(e);
do{n=e.charCodeAt(u++),t=e.charCodeAt(u++),o=e.charCodeAt(u++),f=n<<16|t<<8|o,i=f>>18&63,a=f>>12&63,c=f>>6&63,d=63&f,l[w++]=h.charAt(i)+h.charAt(a)+h.charAt(c)+h.charAt(d)}
while(u<e.length);A=l.join("");var C=e.length%3;return(C?A.slice(0,C-3):A)+"===".slice(C||3)
}
//base64解密
function base64_decode(n){
var r=function(n){
return decodeURIComponent(n.split("").map(function(n)
{
return"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)}).join(""))
};
if("undefined"==typeof window)return new Buffer(n,"base64").toString("utf-8");
if(void 0!==window.atob)return r(window.atob(n));
var e,t,o,i,d,f,a,c,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h=0,w=0,C="",g=[];
if(!n)return n;n+="";
do{
i=u.indexOf(n.charAt(h++)),d=u.indexOf(n.charAt(h++)),f=u.indexOf(n.charAt(h++)),a=u.indexOf(n.charAt(h++)),c=i<<18|d<<12|f<<6|a,e=c>>16&255,t=c>>8&255,o=255&c,g[w++]=64===f?String.fromCharCode(e):64===a?String.fromCharCode(e,t):String.fromCharCode(e,t,o)
}while(h<n.length);
return C=g.join(""),r(C.replace(/\0+$/,""))
}