Olá amigo. Estou com com um problema parecido, se vc puder postar a solução que encontrou, ajudaria muito.
Obrigado.
C
collinsjws
Oi Juno,
Vi um método que descompacta o arquivo utilizando a senha. No meu caso, não precisei quebrar a mesma como achei que teria que fazer. Um outro arquivo trazia informações para que eu gerasse o hash pelo md5 para ser usada neste método.
obs.: Estou tendo problemas com ele quando o arquivo zipado contém arquivos muito grandes. Você pode acompanhar pelo post http://www.guj.com.br/posts/list/217004.java que abri há pouco. Ainda estou tentando resolver.
Abaixo está ele separado.
@SuppressWarnings("CallToThreadDumpStack")publicstaticvoidextrairZipComSenha(finalStringarquivoZipadoComSenha,finalStringdiretorioDestino,finalStringsenha){RandomAccessFilerandomAccessFile=null;ISevenZipInArchiveinArchive=null;//Collinsfinalbyte[]buffer=newbyte[TAMANHO_BUFFER];try{randomAccessFile=newRandomAccessFile(arquivoZipadoComSenha,"r");inArchive=SevenZip.openInArchive(null,// autodetect archive typenewRandomAccessFileInStream(randomAccessFile));// Getting simple interface of the archive inArchiveISimpleInArchivesimpleInArchive=inArchive.getSimpleInterface();for(finalISimpleInArchiveItemitem:simpleInArchive.getArchiveItems()){finalint[]hash=newint[]{0};if(!item.isFolder()){ExtractOperationResultresult;result=item.extractSlow(newISequentialOutStream(){@Override@SuppressWarnings("CallToThreadDumpStack")publicintwrite(finalbyte[]data)throwsSevenZipException{try{if(item.getPath().indexOf(File.separator)>0){Stringpath=diretorioDestino+File.separator+item.getPath().substring(0,item.getPath().lastIndexOf(File.separator));FilefolderExisting=newFile(path);if(!folderExisting.exists()){newFile(path).mkdirs();}}OutputStreamout=newFileOutputStream(diretorioDestino+File.separator+item.getPath());out.write(data);out.close();}catch(Exceptione){e.printStackTrace();}hash[0]|=Arrays.hashCode(data);returndata.length;// Return amount of proceed data}},senha);/// password.if(result==ExtractOperationResult.OK){System.out.println(String.format("%9X | %s",hash[0],item.getPath()));}else{System.err.println("Error extracting item: "+result);}}}}catch(Exceptione){e.printStackTrace();}finally{if(inArchive!=null){try{inArchive.close();}catch(SevenZipExceptione){System.err.println("Error closing archive: "+e);e.printStackTrace();}}if(randomAccessFile!=null){try{randomAccessFile.close();}catch(IOExceptione){System.err.println("Error closing file: "+e);e.printStackTrace();}}}}
B
benignoms
Quem quiser descompactar/compactar arquivos com senha ou sem senha segue abaixo link para excelentes exemplos: