2013-05-08 129 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(); 
    } 
相關問題