@@ -9,6 +9,10 @@ public class UTF8BytesMix {
9
9
10
10
public static byte [] resultBytes = new byte [0 ];
11
11
public static byte [] originalBytes = new byte [0 ];
12
+
13
+ // 加密字节位数
14
+ public static int type = 2 ; //3
15
+
12
16
// 原 byte[] 坐标
13
17
public static int index = 0 ;
14
18
@@ -55,6 +59,7 @@ public static byte[] builder() {
55
59
}
56
60
return resultBytes ;
57
61
}
62
+
58
63
public static void changeTC_PROXYCLASSDESC () {
59
64
int interfaceCount = ((originalBytes [index + 1 ] & 0xFF ) << 24 ) |
60
65
((originalBytes [index + 2 ] & 0xFF ) << 16 ) |
@@ -73,7 +78,7 @@ public static void changeTC_PROXYCLASSDESC() {
73
78
System .arraycopy (originalBytes , index + 3 , originalValue , 0 , length );
74
79
index += 3 + length ;
75
80
76
- encode (originalValue );
81
+ encode (originalValue , type );
77
82
index --;
78
83
}
79
84
@@ -133,7 +138,7 @@ public static boolean changeTC_CLASSDESC() {
133
138
byte [] originalFieldName = new byte [fieldLength ];
134
139
System .arraycopy (originalBytes , index + 2 , originalFieldName , 0 , fieldLength );
135
140
index += 2 + fieldLength ;
136
- encode (originalFieldName );
141
+ encode (originalFieldName , type );
137
142
}
138
143
139
144
/**
@@ -156,7 +161,7 @@ public static boolean changeTC_CLASSDESC() {
156
161
byte [] originalClassName = new byte [classLength ];
157
162
System .arraycopy (originalBytes , index + 2 , originalClassName , 0 , classLength );
158
163
index += 2 + classLength ;
159
- encode (originalClassName );
164
+ encode (originalClassName , type );
160
165
isFiledOver = true ;
161
166
} else if (originalBytes [index ] == TC_REFERENCE ) {
162
167
/**
@@ -212,7 +217,7 @@ public static boolean changeTC_STRING() {
212
217
}
213
218
214
219
index += 3 + length ;
215
- encode (originalValue );
220
+ encode (originalValue , type );
216
221
217
222
index --;
218
223
return true ;
@@ -251,17 +256,36 @@ public static boolean isField(byte[] checkBytes, int index) {
251
256
*
252
257
* @return
253
258
*/
254
- public static void encode (byte [] originalValue ) {
255
- int newLength = originalValue .length * 2 ;
259
+ public static void encode (byte [] originalValue , int type ) {
260
+ if (type == 3 ) {
261
+ // 3 byte format: 1110xxxx 10xxxxxx 10xxxxxx
262
+ int newLength = originalValue .length * 3 ;
263
+
264
+ byteAdd ((byte ) ((newLength >> 8 ) & 0xFF ));
265
+ byteAdd ((byte ) (newLength & 0xFF ));
266
+
267
+ for (int i = 0 ; i < originalValue .length ; i ++) {
268
+ char c = (char ) originalValue [i ];
269
+ byteAdd ((byte ) (0xE0 | ((c >> 12 ) & 0x0F )));
270
+ byteAdd ((byte ) (0x80 | ((c >> 6 ) & 0x3F )));
271
+ byteAdd ((byte ) (0x80 | ((c >> 0 ) & 0x3F )));
272
+ }
256
273
257
- byteAdd ((byte ) ((newLength >> 8 ) & 0xFF ));
258
- byteAdd ((byte ) (newLength & 0xFF ));
274
+ } else {
275
+ // 2 byte format: 110xxxxx 10xxxxxx
276
+ int newLength = originalValue .length * 2 ;
259
277
260
- for (int i = 0 ; i < originalValue .length ; i ++) {
261
- char c = (char ) originalValue [i ];
262
- byteAdd ((byte ) (0xC0 | ((c >> 6 ) & 0x1F )));
263
- byteAdd ((byte ) (0x80 | ((c >> 0 ) & 0x3F )));
278
+ byteAdd ((byte ) ((newLength >> 8 ) & 0xFF ));
279
+ byteAdd ((byte ) (newLength & 0xFF ));
280
+
281
+ for (int i = 0 ; i < originalValue .length ; i ++) {
282
+ char c = (char ) originalValue [i ];
283
+ byteAdd ((byte ) (0xC0 | ((c >> 6 ) & 0x1F )));
284
+ byteAdd ((byte ) (0x80 | ((c >> 0 ) & 0x3F )));
285
+ }
264
286
}
287
+
288
+
265
289
}
266
290
267
291
/**
0 commit comments