Created
February 17, 2016 03:15
-
-
Save as-com/07f0452dcae13da76d01 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/beatgammit/base64-js/blob/master/lib/b64.js | |
!function(r){"use strict";function t(r){var t=f[r.charCodeAt(0)];return void 0!==t?t:-1}function n(r){function n(r){i[f++]=r}var e,a,h,o,c,i;if(r.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var u=r.length;c="="===r.charAt(u-2)?2:"="===r.charAt(u-1)?1:0,i=new A(3*r.length/4-c),h=c>0?r.length-4:r.length;var f=0;for(e=0,a=0;h>e;e+=4,a+=3)o=t(r.charAt(e))<<18|t(r.charAt(e+1))<<12|t(r.charAt(e+2))<<6|t(r.charAt(e+3)),n((16711680&o)>>16),n((65280&o)>>8),n(255&o);return 2===c?(o=t(r.charAt(e))<<2|t(r.charAt(e+1))>>4,n(255&o)):1===c&&(o=t(r.charAt(e))<<10|t(r.charAt(e+1))<<4|t(r.charAt(e+2))>>2,n(o>>8&255),n(255&o)),i}function e(r){return u[r]}function a(r){return e(r>>18&63)+e(r>>12&63)+e(r>>6&63)+e(63&r)}function h(r,t,n){for(var e,h=[],o=t;n>o;o+=3)e=(r[o]<<16)+(r[o+1]<<8)+r[o+2],h.push(a(e));return h.join("")}function o(r){var t,n,a,o=r.length%3,c="",i=[],u=16383;for(t=0,a=r.length-o;a>t;t+=u)i.push(h(r,t,t+u>a?a:t+u));switch(o){case 1:n=r[r.length-1],c+=e(n>>2),c+=e(n<<4&63),c+="==";break;case 2:n=(r[r.length-2]<<8)+r[r.length-1],c+=e(n>>10),c+=e(n>>4&63),c+=e(n<<2&63),c+="="}return i.push(c),i.join("")}var c,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",u=[];for(c=0;c<i.length;c++)u[c]=i[c];var f=[];for(c=0;c<i.length;++c)f[i.charCodeAt(c)]=c;f["-".charCodeAt(0)]=62,f["_".charCodeAt(0)]=63;var A="undefined"!=typeof Uint8Array?Uint8Array:Array;r.toByteArray=n,r.fromByteArray=o}("undefined"==typeof exports?this.base64js={}:exports); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment