PageSourceSearch

https://jwxt.tsnu.edu.cn/jw/custom/js/base64.js?t=93585179133462479857147

js tsnu.edu.cn collected 2026-10-07 00:57:34 UTC 4,839 bytes, 157 lines download raw bytes

1function utf16to8(str) {
2    var out, i, len, c;
3
4    out = "";
5    len = str.length;
6    for(i = 0; i < len; i++) {
7        c = str.charCodeAt(i);
8        if ((c >= 0x0001) && (c <= 0x007F)) {
9            out += str.charAt(i);
10        } else if (c > 0x07FF) {
11            out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));
12            out += String.fromCharCode(0x80 | ((c >>  6) & 0x3F));
13            out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));
14        } else {
15            out += String.fromCharCode(0xC0 | ((c >>  6) & 0x1F));
16            out += String.fromCharCode(0x80 | ((c >>  0) & 0x3F));
17        }
18    }
19    return out;
20}
21function utf8to16(str) {
22    var out, i, len, c;
23    var char2, char3;
24
25    out = "";
26    len = str.length;
27    i = 0;
28    while(i < len) {
29        c = str.charCodeAt(i++);
30        switch(c >> 4)
31        {
32          case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
33            // 0xxxxxxx
34            out += str.charAt(i-1);
35            break;
36          case 12: case 13:
37            // 110x xxxx   10xx xxxx
38            char2 = str.charCodeAt(i++);
39            out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
40            break;
41          case 14:
42            // 1110 xxxx  10xx xxxx  10xx xxxx
43            char2 = str.charCodeAt(i++);
44            char3 = str.charCodeAt(i++);
45            out += String.fromCharCode(((c & 0x0F) << 12) |
46                                           ((char2 & 0x3F) << 6) |
47                                           ((char3 & 0x3F) << 0));
48            break;
49        }
50    }
51
52    return out;
53}
54
55var base64EncodeChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
56var base64DecodeChars = new Array(
57    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
58    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
59    -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
60    52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
61    -1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,
62    15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
63    -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
64    41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
65
66function base64encode(str) {
67    var out, i, len;
68    var c1, c2, c3;
69
70    len = str.length;
71    i = 0;
72    out = "";
73    while(i < len) {
74        c1 = str.charCodeAt(i++) & 0xff;
75        if(i == len)
76        {
77            out += base64EncodeChars.charAt(c1 >> 2);
78            out += base64EncodeChars.charAt((c1 & 0x3) << 4);
79            out += "==";
80            break;
81        }
82        c2 = str.charCodeAt(i++);
83        if(i == len)
84        {
85            out += base64EncodeChars.charAt(c1 >> 2);
86            out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
87            out += base64EncodeChars.charAt((c2 & 0xF) << 2);
88            out += "=";
89            break;
90        }
91        c3 = str.charCodeAt(i++);
92        out += base64EncodeChars.charAt(c1 >> 2);
93        out += base64EncodeChars.charAt(((c1 & 0x3)<< 4) | ((c2 & 0xF0) >> 4));
94        out += base64EncodeChars.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >>6));
95        out += base64EncodeChars.charAt(c3 & 0x3F);
96    }
97    return out;
98}
99
100function base64decode(str) {
101    var c1, c2, c3, c4;
102    var i, len, out;
103
104    len = str.length;
105    i = 0;
106    out = "";
107    while(i < len) {
108        /* c1 */
109        do {
110            c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
111        } while(i < len && c1 == -1);
112        if(c1 == -1)
113            break;
114
115        /* c2 */
116        do {
117            c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
118        } while(i < len && c2 == -1);
119        if(c2 == -1)
120            break;
121
122        out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
123
124        /* c3 */
125        do {
126            c3 = str.charCodeAt(i++) & 0xff;
127            if(c3 == 61)
128                return out;
129            c3 = base64DecodeChars[c3];
130        } while(i < len && c3 == -1);
131        if(c3 == -1)
132            break;
133
134        out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
135
136        /* c4 */
137        do {
138            c4 = str.charCodeAt(i++) & 0xff;
139            if(c4 == 61)
140                return out;
141            c4 = base64DecodeChars[c4];
142        } while(i < len && c4 == -1);
143        if(c4 == -1)
144            break;
145        out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
146    }
147    return out;
148}
149//js_base64 encode
150function str_encode(str){
151  return base64encode(utf16to8(str));
152} 
153//js_base64 decode
154function str_decode(str){
155  return utf8to16(base64decode(str));
156}
157

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.