protected void add(ZipFile inFile, String password) throws IOException, UnsupportedEncodingException { ZipFileEntryInputStream zfe = new ZipFileEntryInputStream(inFile.getName()); try { Enumeration<? extends ZipEntry> en = inFile.entries(); while (en.hasMoreElements()) { ZipEntry ze = en.nextElement(); zfe.nextEntry(ze); add(ze, zfe, password); } } finally { zfe.close(); } }
public int read( byte[] b ) throws IOException { return this.read(b, 0, b.length); }
protected void add(ZipFile inFile, String password) throws IOException, UnsupportedEncodingException { ZipFileEntryInputStream zfe = new ZipFileEntryInputStream(inFile.getName()); try { Enumeration<? extends ZipEntry> en = inFile.entries(); while (en.hasMoreElements()) { ZipEntry ze = en.nextElement(); zfe.nextEntry(ze); add(ze, zfe, password); } } finally { zfe.close(); } }
public int read( byte[] b ) throws IOException { return this.read(b, 0, b.length); }
protected void add(ZipEntry zipEntry, ZipFileEntryInputStream zipData, String password) throws IOException, UnsupportedEncodingException { encrypter.init(password, 256); ExtZipEntry entry = new ExtZipEntry(zipEntry.getName()); entry.setMethod(zipEntry.getMethod()); entry.setSize(zipEntry.getSize()); entry.setCompressedSize(zipEntry.getCompressedSize() + 28); entry.setTime(zipEntry.getTime()); entry.initEncryptedEntry(); zipOS.putNextEntry(entry); // ZIP-file data contains: 1. salt 2. pwVerification 3. encryptedContent 4. authenticationCode zipOS.writeBytes(encrypter.getSalt()); zipOS.writeBytes(encrypter.getPwVerification()); byte[] data = new byte[1024]; int read = zipData.read(data); while (read != -1) { encrypter.encrypt(data, read); zipOS.writeBytes(data, 0, read); read = zipData.read(data); } byte[] finalAuthentication = encrypter.getFinalAuthentication(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("finalAuthentication=" + Arrays.toString(finalAuthentication) + " at pos=" + zipOS.getWritten()); } zipOS.writeBytes(finalAuthentication); }
protected void add(ZipEntry zipEntry, ZipFileEntryInputStream zipData, String password) throws IOException, UnsupportedEncodingException { encrypter.init(password, 256); ExtZipEntry entry = new ExtZipEntry(zipEntry.getName()); entry.setMethod(zipEntry.getMethod()); entry.setSize(zipEntry.getSize()); entry.setCompressedSize(zipEntry.getCompressedSize() + 28); entry.setTime(zipEntry.getTime()); entry.initEncryptedEntry(); zipOS.putNextEntry(entry); // ZIP-file data contains: 1. salt 2. pwVerification 3. encryptedContent 4. authenticationCode zipOS.writeBytes(encrypter.getSalt()); zipOS.writeBytes(encrypter.getPwVerification()); byte[] data = new byte[1024]; int read = zipData.read(data); while (read != -1) { encrypter.encrypt(data, read); zipOS.writeBytes(data, 0, read); read = zipData.read(data); } byte[] finalAuthentication = encrypter.getFinalAuthentication(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("finalAuthentication=" + Arrays.toString(finalAuthentication) + " at pos=" + zipOS.getWritten()); } zipOS.writeBytes(finalAuthentication); }