Created
April 22, 2014 09:49
-
-
Save MrPoofy/11172385 to your computer and use it in GitHub Desktop.
Decoder for base64 strings.
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
/* ========================================================================== | |
Decoder for Base64 strings. | |
Created by Broc Seib @http://blog.broc.seib.net | |
========================================================================== */ | |
decode_Base64 = function(s) { | |
var e={},i,b=0,c,x,l=0,a,r='',w=String.fromCharCode,L=s.length; | |
var A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | |
for(i=0;i<64;i++){e[A.charAt(i)]=i;} | |
for(x=0;x<L;x++){ | |
c=e[s.charAt(x)];b=(b<<6)+c;l+=6; | |
while(l>=8){((a=(b>>>(l-=8))&0xff)||(x<(L-2)))&&(r+=w(a));} | |
} | |
return r; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment