import
java.io.ByteArrayOutputStream;
import
java.io.File;
import
java.io.FileInputStream;
import
java.io.FileOutputStream;
import
java.io.IOException;
import
java.util.Enumeration;
import
java.util.zip.*;
public
class
solution {
public
static
byte
[] encDesSimple(
byte
[] bArr,
int
[] iArr) {
int
length = bArr.length;
for
(
int
i =
0
; i < length; i++) {
if
(bArr[i] >=
0
) {
bArr[i] = (
byte
) iArr[bArr[i]];
}
}
return
bArr;
}
public
static
void
writeFileBytes(File file,
byte
[] bArr) {
try
{
FileOutputStream fileOutputStream =
new
FileOutputStream(file);
fileOutputStream.write(bArr);
fileOutputStream.flush();
fileOutputStream.close();
}
catch
(Exception e) {
e.printStackTrace();
}
}
public
static
byte
[] readFileBytes(File file)
throws
IOException {
byte
[] bArr =
new
byte
[
1024
];
ByteArrayOutputStream byteArrayOutputStream =
new
ByteArrayOutputStream();
FileInputStream fileInputStream =
new
FileInputStream(file);
while
(
true
) {
int
read = fileInputStream.read(bArr);
if
(read != -
1
) {
byteArrayOutputStream.write(bArr,
0
, read);
}
else
{
fileInputStream.close();
return
byteArrayOutputStream.toByteArray();
}
}
}
public
static
void
main(String args[])
{
try
{
Enumeration<?
extends
ZipEntry> entries
=
new
ZipFile(
"test"
).entries();
int
i =
0
;
String soname =
"libkiwi_enc.so"
;
while
(
true
) {
if
(!entries.hasMoreElements()) {
break
;
}
ZipEntry nextElement = entries.nextElement();
String comment = nextElement.getComment();
if
(comment !=
null
&& !comment.equals(
""
)) {
System.out.println(
"comment = "
+ comment);
i++;
}
System.out.println(
"count = "
+ i);
}
int
[] iArr = {
73
,
76
,
74
,
98
,
77
,
115
,
124
,
103
,
68
,
99
,
75
,
104
,
85
,
126
,
105
,
83
,
117
,
93
,
112
,
121
,
96
,
102
,
111
,
114
,
66
,
94
,
81
,
125
,
127
,
113
,
90
,
123
,
84
,
88
,
65
,
107
,
87
,
116
,
91
,
120
,
118
,
106
,
101
,
110
,
69
,
78
,
122
,
82
,
89
,
70
,
100
,
72
,
67
,
64
,
80
,
97
,
119
,
109
,
92
,
108
,
79
,
95
,
86
,
71
,
53
,
34
,
24
,
52
,
8
,
44
,
49
,
63
,
51
,
0
,
2
,
10
,
1
,
4
,
45
,
60
,
54
,
26
,
47
,
15
,
32
,
12
,
62
,
36
,
33
,
48
,
30
,
38
,
58
,
17
,
25
,
61
,
20
,
55
,
3
,
9
,
50
,
42
,
21
,
7
,
11
,
14
,
41
,
35
,
59
,
57
,
43
,
22
,
18
,
29
,
23
,
5
,
37
,
16
,
40
,
56
,
39
,
19
,
46
,
31
,
6
,
27
,
13
,
28
};
writeFileBytes(
new
File(soname.replace(
"_enc"
,
""
)), encDesSimple(readFileBytes(
new
File(soname)), iArr));
}
catch
(Exception e) {
System.out.println(e.getMessage());
}
}
}