base64.json
3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
[
"/*\n * https://github.com/davidchambers/Base64.js\n */","\n",
";","(","function"," ","(",")"," ","{","\n\n ",
"var"," ","object"," ","="," ","typeof"," ","exports"," ","!="," ","'undefined'"," ","?"," ","exports"," ",":"," ","this",";"," ","// #8: web workers","\n ",
"var"," ","chars"," ","="," ","'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='",";","\n\n ",
"function"," ","InvalidCharacterError","(","message",")"," ","{","\n ",
"this",".","message"," ","="," ","message",";","\n ",
"}","\n ",
"InvalidCharacterError",".","prototype"," ","="," ","new"," ","Error",";","\n ",
"InvalidCharacterError",".","prototype",".","name"," ","="," ","'InvalidCharacterError'",";","\n\n ",
"// encoder","\n ",
"// [https://gist.github.com/999166] by [https://github.com/nignag]","\n ",
"object",".","btoa"," ","||"," ","(","\n ",
"object",".","btoa"," ","="," ","function"," ","(","input",")"," ","{","\n ",
"for"," ","(","\n ",
"// initialize result and counter","\n ",
"var"," ","block",","," ","charCode",","," ","idx"," ","="," ","0",","," ","map"," ","="," ","chars",","," ","output"," ","="," ","''",";","\n ",
"// if the next input index does not exist:","\n ",
"// change the mapping table to \"=\"","\n ",
"// check if d has no fractional digits","\n ",
"input",".","charAt","(","idx"," ","|"," ","0",")"," ","||"," ","(","map"," ","="," ","'='",","," ","idx"," ","%"," ","1",")",";","\n ",
"// \"8 - idx % 1 * 8\" generates the sequence 2, 4, 6, 8","\n ",
"output"," ","+="," ","map",".","charAt","(","63"," ","&"," ","block"," ",">>"," ","8"," ","-"," ","idx"," ","%"," ","1"," ","*"," ","8",")","\n ",
")"," ","{","\n ",
"charCode"," ","="," ","input",".","charCodeAt","(","idx"," ","+="," ","3","/","4",")",";","\n ",
"if"," ","(","charCode"," ",">"," ","0xFF",")"," ","{","\n ",
"throw"," ","new"," ","InvalidCharacterError","(","\"'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.\"",")",";","\n ",
"}","\n ",
"block"," ","="," ","block"," ","<<"," ","8"," ","|"," ","charCode",";","\n ",
"}","\n ",
"return"," ","output",";","\n ",
"}",")",";","\n\n ",
"// decoder","\n ",
"// [https://gist.github.com/1020396] by [https://github.com/atk]","\n ",
"object",".","atob"," ","||"," ","(","\n ",
"object",".","atob"," ","="," ","function"," ","(","input",")"," ","{","\n ",
"input"," ","="," ","input",".","replace","(","/=+$/",","," ","''",")","\n ",
"if"," ","(","input",".","length"," ","%"," ","4"," ","=="," ","1",")"," ","{","\n ",
"throw"," ","new"," ","InvalidCharacterError","(","\"'atob' failed: The string to be decoded is not correctly encoded.\"",")",";","\n ",
"}","\n ",
"for"," ","(","\n ",
"// initialize result and counters","\n ",
"var"," ","bc"," ","="," ","0",","," ","bs",","," ","buffer",","," ","idx"," ","="," ","0",","," ","output"," ","="," ","''",";","\n ",
"// get next character","\n ",
"buffer"," ","="," ","input",".","charAt","(","idx","++",")",";","\n ",
"// character found in table? initialize bit storage and add its ascii value;","\n ",
"~","buffer"," ","&&"," ","(","bs"," ","="," ","bc"," ","%"," ","4"," ","?"," ","bs"," ","*"," ","64"," ","+"," ","buffer"," ",":"," ","buffer",",","\n ",
"// and if not first of each 4 characters,","\n ",
"// convert the first 8 bits to one ascii character","\n ",
"bc","++"," ","%"," ","4",")"," ","?"," ","output"," ","+="," ","String",".","fromCharCode","(","255"," ","&"," ","bs"," ",">>"," ","(","-","2"," ","*"," ","bc"," ","&"," ","6",")",")"," ",":"," ","0","\n ",
")"," ","{","\n ",
"// try to find character in table (0-63, not found => -1)","\n ",
"buffer"," ","="," ","chars",".","indexOf","(","buffer",")",";","\n ",
"}","\n ",
"return"," ","output",";","\n ",
"}",")",";","\n\n",
"}","(",")",")",";","\n"
]