import TeenPatti1.MD5Util;
import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.model.FileHeader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;
public class v2签名 {
public static void main(String[] args) {
File file = new File("aaaaa.apk");
ZipFile zipFile = new ZipFile(file);
try {
List<FileHeader> fileHeaderList = zipFile.getFileHeaders();
FileHeader fileHeader = fileHeaderList.get(fileHeaderList.size() - 1);
long offset = fileHeader.getOffsetLocalHeader()
+ fileHeader.getFileNameLength()
+ fileHeader.getFileCommentLength()
+ fileHeader.getExtraFieldLength()
+ fileHeader.getCompressedSize() + 30;
FileInputStream fileInputStream = new FileInputStream(file);
fileInputStream.skip(offset);
int signDataTotal = 0;
while ((signDataTotal = fileInputStream.read()) == 0) {
}
System.out.println(signDataTotal);
for (int i = 8; i < 64; i += 8) {
signDataTotal |= fileInputStream.read() << i;
}
System.out.println(signDataTotal);
long long1 = readLong(fileInputStream);
int crc = readInt(fileInputStream);
System.out.println(crc);
if (crc != 1896449818) {
throw new Exception("");
}
int int1 = readInt(fileInputStream);
int int2 = readInt(fileInputStream);
int int3 = readInt(fileInputStream);
int headInt1 = readInt(fileInputStream);
fileInputStream.skip(headInt1);
int int4 = readInt(fileInputStream);
int int5 = readInt(fileInputStream);
System.out.println(int5);
byte[] bytes = new byte[int5];
fileInputStream.read(bytes);
if (int5 - 4 != (bytes[2] * 0x100) + (bytes[3] & 0xFF)) {
throw new Exception("长度出问题");
}
System.out.println(MD5Util.byte2MD5(bytes));
} catch (Exception e) {
e.printStackTrace();
}
}
private static final long readLong(InputStream inputStream) throws Exception {
return inputStream.read()
| inputStream.read() << 8
| inputStream.read() << 16
| inputStream.read() << 24
| inputStream.read() << 32
| inputStream.read() << 40
| inputStream.read() << 48
| inputStream.read() << 56;
}
private static final int readInt(InputStream inputStream) throws Exception {
return inputStream.read()
| inputStream.read() << 8
| inputStream.read() << 16
| inputStream.read() << 24;
}
}