@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( "fileName\t\t = " ).append( this.fileName ).append('\n'); try { sb.append( "uncompressedSize\t = " ).append( this.getUncompressedSize() ).append('\n'); sb.append( "compressedSize\t\t = " ).append( this.getCompressedSize() ).append('\n'); sb.append( "encryptionStrength\t = ").append( this.getEncryptionStrength() ).append('\n'); sb.append( "extraFieldOffset\t = " ).append( this.getExtraFieldOffset() ).append('\n'); sb.append( "extraFieldLength\t = " ).append( this.getExtraFieldLength() ).append('\n'); sb.append( "localHeaderOffset\t = " ).append( this.getLocalHeaderOffset() ).append('\n'); sb.append( "localHeaderSize\t\t = " ).append( this.getLocalHeaderSize() ).append('\n'); sb.append( "offset\t\t\t = ").append( this.getOffset() ).append('\n'); //sb.append().append().append('\n'); } catch( IOException ioEx ) { LOG.log(Level.WARNING, ioEx.getMessage(), ioEx); } return sb.toString(); }
/** * @return position within zip file where the actual data of the entry (file) starts * (after encryption salt + pw data) */ public int getOffset() { return (int)(getLocalHeaderOffset() + getLocalHeaderSize() + getCryptoHeaderLength()); }
String fileName = new String( fileNameBytes, charset ); CentralDirectoryEntry cde = new CentralDirectoryEntry( raFile, fileOffset ); ExtZipEntry zipEntry = new ExtZipEntry( fileName, cde ); zipEntry.setCompressedSize( cde.getCompressedSize() ); zipEntry.setSize( cde.getUncompressedSize() ); if( cde.isEncrypted() ) { zipEntry.setMethod( cde.getActualCompressionMethod() ); zipEntry.setOffset( (int)(cde.getLocalHeaderOffset() + cde.getLocalHeaderSize()) + cde.getCryptoHeaderLength() ); zipEntry.initEncryptedEntry(); } else {
if( !cde.isAesEncrypted() ) { throw new ZipException("only AES encrypted files are supported"); int cryptoHeaderOffset = zipEntry.getOffset() - cde.getCryptoHeaderLength(); LOG.finest( "\n" + cde.toString() ); LOG.finest( "offset = " + zipEntry.getOffset() ); LOG.finest( "cryptoOff = " + cryptoHeaderOffset ); zos.putNextEntry( tmpEntry ); raFile.seek( cde.getOffset() ); byte[] buffer = new byte[bufferSize]; int remaining = (int)zipEntry.getEncryptedDataSize();
this.actualCompressionMethod = raFile.readShort( getExtraFieldOffset() + 9 ); this.localHeaderSize = 30 + getExtraFieldLength() + getFileNameLength();
/** * this library currently only supports 256bit keys * * @return keySize - 1=128bit | 2=192bit | 3=256bit */ public byte getEncryptionStrength() throws IOException { return raFile.readByte( getExtraFieldOffset() + 8 ); }
String fileName = new String( fileNameBytes, charset ); CentralDirectoryEntry cde = new CentralDirectoryEntry( raFile, fileOffset ); ExtZipEntry zipEntry = new ExtZipEntry( fileName, cde ); zipEntry.setCompressedSize( cde.getCompressedSize() ); zipEntry.setSize( cde.getUncompressedSize() ); if( cde.isEncrypted() ) { zipEntry.setMethod( cde.getActualCompressionMethod() ); zipEntry.setOffset( (int)(cde.getLocalHeaderOffset() + cde.getLocalHeaderSize()) + cde.getCryptoHeaderLength() ); zipEntry.initEncryptedEntry(); } else {
if( !cde.isAesEncrypted() ) { throw new ZipException("only AES encrypted files are supported"); int cryptoHeaderOffset = zipEntry.getOffset() - cde.getCryptoHeaderLength(); LOG.finest( "\n" + cde.toString() ); LOG.finest( "offset = " + zipEntry.getOffset() ); LOG.finest( "cryptoOff = " + cryptoHeaderOffset ); zos.putNextEntry( tmpEntry ); raFile.seek( cde.getOffset() ); byte[] buffer = new byte[bufferSize]; int remaining = (int)zipEntry.getEncryptedDataSize();
this.actualCompressionMethod = raFile.readShort( getExtraFieldOffset() + 9 ); this.localHeaderSize = 30 + getExtraFieldLength() + getFileNameLength();
/** * this library currently only supports 256bit keys * * @return keySize - 1=128bit | 2=192bit | 3=256bit */ public byte getEncryptionStrength() throws IOException { return raFile.readByte( getExtraFieldOffset() + 8 ); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( "fileName\t\t = " ).append( this.fileName ).append('\n'); try { sb.append( "uncompressedSize\t = " ).append( this.getUncompressedSize() ).append('\n'); sb.append( "compressedSize\t\t = " ).append( this.getCompressedSize() ).append('\n'); sb.append( "encryptionStrength\t = ").append( this.getEncryptionStrength() ).append('\n'); sb.append( "extraFieldOffset\t = " ).append( this.getExtraFieldOffset() ).append('\n'); sb.append( "extraFieldLength\t = " ).append( this.getExtraFieldLength() ).append('\n'); sb.append( "localHeaderOffset\t = " ).append( this.getLocalHeaderOffset() ).append('\n'); sb.append( "localHeaderSize\t\t = " ).append( this.getLocalHeaderSize() ).append('\n'); sb.append( "offset\t\t\t = ").append( this.getOffset() ).append('\n'); //sb.append().append().append('\n'); } catch( IOException ioEx ) { LOG.log(Level.WARNING, ioEx.getMessage(), ioEx); } return sb.toString(); }
try { CentralDirectoryEntry cde = zipEntry.getCentralDirectoryEntry(); if (!cde.isAesEncrypted()) { throw new ZipException("only AES encrypted files are supported"); int cryptoHeaderOffset = zipEntry.getOffset() - cde.getCryptoHeaderLength(); byte[] salt = raFile.readByteArray(cryptoHeaderOffset, 16); byte[] pwVerification = raFile.readByteArray(cryptoHeaderOffset + 16, 2); if (LOG.isLoggable(Level.FINEST)) { LOG.finest("\n" + cde.toString()); LOG.finest("offset = " + zipEntry.getOffset()); LOG.finest("cryptoOff = " + cryptoHeaderOffset); tmpEntry.setCompressedSize(zipEntry.getEncryptedDataSize()); zos.putNextEntry(tmpEntry); raFile.seek(cde.getOffset()); byte[] buffer = new byte[bufferSize]; int remaining = (int) zipEntry.getEncryptedDataSize();
/** * @return position within zip file where the actual data of the entry (file) starts * (after encryption salt + pw data) */ public int getOffset() { return (int)(getLocalHeaderOffset() + getLocalHeaderSize() + getCryptoHeaderLength()); }
try { CentralDirectoryEntry cde = zipEntry.getCentralDirectoryEntry(); if (!cde.isAesEncrypted()) { throw new ZipException("only AES encrypted files are supported"); int cryptoHeaderOffset = zipEntry.getOffset() - cde.getCryptoHeaderLength(); byte[] salt = raFile.readByteArray(cryptoHeaderOffset, 16); byte[] pwVerification = raFile.readByteArray(cryptoHeaderOffset + 16, 2); if (LOG.isLoggable(Level.FINEST)) { LOG.finest("\n" + cde.toString()); LOG.finest("offset = " + zipEntry.getOffset()); LOG.finest("cryptoOff = " + cryptoHeaderOffset); tmpEntry.setCompressedSize(zipEntry.getEncryptedDataSize()); zos.putNextEntry(tmpEntry); raFile.seek(cde.getOffset()); byte[] buffer = new byte[bufferSize]; CRC32 crc32 = new CRC32();
try { CentralDirectoryEntry cde = zipEntry.getCentralDirectoryEntry(); if (!cde.isAesEncrypted()) { throw new ZipException("only AES encrypted files are supported"); int cryptoHeaderOffset = zipEntry.getOffset() - cde.getCryptoHeaderLength(); byte[] salt = raFile.readByteArray(cryptoHeaderOffset, 16); byte[] pwVerification = raFile.readByteArray(cryptoHeaderOffset + 16, 2); if (LOG.isLoggable(Level.FINEST)) { LOG.finest("\n" + cde.toString()); LOG.finest("offset = " + zipEntry.getOffset()); LOG.finest("cryptoOff = " + cryptoHeaderOffset); tmpEntry.setCompressedSize(zipEntry.getEncryptedDataSize()); zos.putNextEntry(tmpEntry); raFile.seek(cde.getOffset()); byte[] buffer = new byte[bufferSize];