2013-05-08 131 views
1

有谁知道使用TrueZip创建受密码保护的ZIP文件的好例子吗?使用TrueZip创建受密码保护的ZIP文件

我跟着给出的例子TrueZip Example,但同时提取密码保护的zip文件不接受我通过java代码设置正确的密码。

+1

什么工具解决?每个应用程序都不支持AES加密的ZIP文件。 – 2013-05-08 17:25:32

+0

首先,我通过java代码创建zip文件,并且由于我需要制作受密码保护的zip文件,因此我使用TrueZip,因为它具有eclipse许可证。 – Shashwat 2013-05-08 19:48:55

+1

但是您尝试解压缩该zip文件的工具是什么? – 2013-05-08 20:01:04

回答

2

我发现这一点,你试图提取密码保护的文件

try { 
     final TConfig config = TConfig.get(); 

     // Request encryption in archive files. 
     config.setOutputPreferences(config.getOutputPreferences() 
       .or(BitField.of(FsOutputOption.ENCRYPT))); 

     // Configure archive detector with custom key management for ZIP files. 
     config.setArchiveDetector(newArchiveDetector1("zip", "password")); 

     // Setup file paths. 
     TFile src = new TFile("file1"); 
     TFile dst = new TFile("file2"); 
     if (dst.isArchive() || dst.isDirectory()) 
      dst = new TFile(dst, src.getName()); 

     // Recursive copy. 
     src.cp_rp(dst); 
    } finally { 
     // Commit changes. 
     TVFS.umount(); 
    } 
相关问题