encrypter.init(password, 256); zipOS.writeBytes(encrypter.getSalt()); zipOS.writeBytes(encrypter.getPwVerification()); encrypter.encrypt(data, data.length); zipOS.writeBytes(data, 0, data.length); byte[] finalAuthentication = encrypter.getFinalAuthentication(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("finalAuthentication=" + Arrays.toString(finalAuthentication) + " at pos="
encrypter.init(password, 256); zipOS.writeBytes(encrypter.getSalt()); zipOS.writeBytes(encrypter.getPwVerification()); encrypter.encrypt(data, data.length); zipOS.writeBytes(data, 0, data.length); byte[] finalAuthentication = encrypter.getFinalAuthentication(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("finalAuthentication=" + Arrays.toString(finalAuthentication) + " at pos="
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); }