Package com.zwl.util.zip.impl

Examples of com.zwl.util.zip.impl.ExtZipEntry


      byte[] fileNameBytes = raFile.readByteArray( fileOffsetPos+4, fileNameLength );
      long nextFileOffset = raFile.getFilePointer();
      String fileName = new String( fileNameBytes, charset );
     
      ExtZipEntry zipEntry = new ExtZipEntry( fileName );

      CentralDirectoryEntry cde = new CentralDirectoryEntry( raFile, fileOffset );
      zipEntry.setCentralDirectoryEntry( cde );

      zipEntry.setCompressedSize( cde.getCompressedSize() );
      zipEntry.setSize( cde.getUncompressedSize() );

      long dosTime = raFile.readInt( fileOffset + 12 );
      zipEntry.setTime( ExtZipEntry.dosToJavaTime(dosTime) );
     
      if( cde.isEncrypted() ) {
        zipEntry.setMethod( cde.getActualCompressionMethod() );
        zipEntry.setOffset( (int)(cde.getLocalHeaderOffset() + cde.getLocalHeaderSize()) + cde.getCryptoHeaderLength() );
        zipEntry.initEncryptedEntry();
      } else {
        zipEntry.setMethod( ZipEntry.DEFLATED );
        zipEntry.setPrimaryCompressionMethod( ZipEntry.DEFLATED );
      }

      nextFileOffset += extraFieldLength;

      out.add(zipEntry);
View Full Code Here


      // create tmp file to contains the decrypted, but still compressed data
      File tmpFile = new File( outFile.getPath() + "_TMP.zip" );
      makeDir( new File(tmpFile.getParent()) );
      ExtZipOutputStream zos = new ExtZipOutputStream( tmpFile );
      ExtZipEntry tmpEntry = new ExtZipEntry( zipEntry );
      tmpEntry.setPrimaryCompressionMethod( zipEntry.getMethod() );
      zos.putNextEntry( tmpEntry );

      raFile.seek( cde.getOffset() );
      byte[] buffer = new byte[bufferSize];
      int remaining = (int)zipEntry.getEncryptedDataSize();
View Full Code Here

  /** testcode + usage example */
  public static void main( String[] args ) throws Exception {
    //LogManager.getLogManager().readConfiguration( new FileInputStream("logging.properties") );
    AesZipFileDecrypter zipFile = new AesZipFileDecrypter( new File("doc/zipSpecificationAes.zip") );
    ExtZipEntry entry = zipFile.getEntry( "zipSpecification.txt" );
    zipFile.extractEntry( entry, new File("doc/zipSpecification.txt"), "foo" );
  }
View Full Code Here

  // TODO - zipEntry might use extended local header
  protected void add(ZipEntry zipEntry, ZipFileEntryInputStream zipData, String password)
      throws IOException, UnsupportedEncodingException {
    AESEncrypter aesEncrypter = new AESEncrypterBC(password.getBytes("iso-8859-1"));

    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(aesEncrypter.getSalt());
    zipOS.writeBytes(aesEncrypter.getPwVerification());
View Full Code Here

      dos.write(buf, 0, read);
    }
    dos.close();
    byte[] data = bos.toByteArray();

    ExtZipEntry entry = new ExtZipEntry(name);
    entry.setMethod(ZipEntry.DEFLATED);
    entry.setSize(inputLen);
    entry.setCompressedSize(data.length + 28);
    entry.setTime((new java.util.Date()).getTime());
    entry.initEncryptedEntry();

    zipOS.putNextEntry(entry);
    // ZIP-file data contains: 1. salt 2. pwVerification 3. encryptedContent 4. authenticationCode
    zipOS.writeBytes(aesEncrypter.getSalt());
    zipOS.writeBytes(aesEncrypter.getPwVerification());
View Full Code Here

TOP

Related Classes of com.zwl.util.zip.impl.ExtZipEntry

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.