fa-toolkit
Version:
a devtool for fast app
1 lines • 934 B
JavaScript
;var decoder,Base64={decode:function(e){if(void 0===decoder){var r="= \f\n\r\t \u2028\u2029";for(decoder=[],c=0;c<64;++c)decoder["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c)]=c;for(c=0;c<r.length;++c)decoder[r.charAt(c)]=-1}for(var t=[],a=0,o=0,c=0;c<e.length;++c){var n=e.charAt(c);if("="==n)break;if(-1!=(n=decoder[n])){if(void 0===n)throw"Illegal character at offset "+c;a|=n,4<=++o?(t[t.length]=a>>16,t[t.length]=a>>8&255,t[t.length]=255&a,o=a=0):a<<=6}}switch(o){case 1:throw"Base64 encoding incomplete: at least 2 bits missing";case 2:t[t.length]=a>>10;break;case 3:t[t.length]=a>>16,t[t.length]=a>>8&255}return t},re:/-----BEGIN [^-]+-----([A-Za-z\d+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z\d+\/=\s]+)====/,unarmor:function(e){var r=Base64.re.exec(e);if(r)if(r[1])e=r[1];else{if(!r[2])throw"RegExp out of sync";e=r[2]}return Base64.decode(e)}};module.exports=Base64;