문제

Does anyone know any good example to creating password protected ZIP file using TrueZip?

I followed the the example given TrueZip Example but while extracting password protected zip file is not accepting the correct password which I set through java code.

도움이 되었습니까?

해결책

I found the solution for this

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();
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top