Created
November 6, 2013 07:36
-
-
Save wang-bin/7332335 to your computer and use it in GitHub Desktop.
js base64 to ArrayBuffer
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
decode64: function decodeBase64(en) { | |
var de = new Uint8Array(en.length); //3/4 | |
var u = 0, q = '', x = '', c; | |
var map64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
for (var r=0; c=en[x++]; ~c&&(u=q%4?u*64+c:c,q++%4)?de[r++]=(255&u>>(-2*q&6)):0) | |
c = map64.indexOf(c); | |
var sub = de.subarray||de.subset||de.slice; | |
return sub.call(de, 0, r); | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment