62,636
社区成员




public void encrpt(String jarfile, String desFile) throws IOException {
String tempDesFile=desFile;
if(jarfile.equalsIgnoreCase(desFile)){
tempDesFile+="_tem";
}
File f = new File(tempDesFile);
if (f.exists()) {
f.delete();
}
JarOutputStream jaros = new JarOutputStream(new FileOutputStream(
tempDesFile));
JarFile jarf = new JarFile(jarfile);
// byte[] buf = new byte[1024];
for (Enumeration<JarEntry> en = jarf.entries(); en.hasMoreElements();) {
JarEntry entry = en.nextElement();
jaros.putNextEntry(new JarEntry(entry.getName()));
InputStream entryIn = jarf.getInputStream(entry);
byte[] encryData;
byte[] classData = getByteData(entryIn);
String extName = "";
int index = entry.getName().lastIndexOf(".");
if (index != -1) {
extName = entry.getName().substring(index + 1);
}
if (this.encyptType.contains(extName) && crptor != null) {
encryData = crptor.encrpt(classData);
} else {
encryData = classData;
}
jaros.write(encryData, 0, encryData.length);
jaros.closeEntry();
}
jarf.close();
jaros.close();
Util.rename(tempDesFile, desFile);
}