/** * Encrypt all files from an existing zip to one new "zipOutFile" using "password". */ public static void zipAndEncryptAll(File inZipFile, File outFile, String password, AESEncrypter encrypter) throws IOException { AesZipFileEncrypter enc = new AesZipFileEncrypter(outFile,encrypter); try { enc.addAll(inZipFile, password); } finally { enc.close(); } }
/** * Zip + encrypt one "inFile" to one "outZipFile" using "password". */ public static void zipAndEncrypt(File inFile, File outFile, String password, AESEncrypter encrypter) throws IOException { AesZipFileEncrypter enc = new AesZipFileEncrypter(outFile,encrypter); try { enc.add(inFile, password); } finally { enc.close(); } }
public AesZipFileDecrypter( File zipFile, AESDecrypter decrypter ) throws IOException { this.zipFile = zipFile; this.decrypter = decrypter; this.raFile = new ExtRandomAccessFile( zipFile ); initDirOffsetPosAndComment(); }
/** * Add un-encrypted + un-zipped file to encrypted zip file.<br> * * @param file to add * @param pathForEntry to be used for addition of the file (path within zip file) * @param password to be used for encryption */ public void add(File file, String pathForEntry, String password) throws IOException, UnsupportedEncodingException { FileInputStream fis = new FileInputStream(file); try { add(pathForEntry, fis, password); } finally { fis.close(); } }
private ExtZipEntry findZipEntry(String regex) throws IOException { for(ExtZipEntry ze : azfd.getEntryList()) { if(ze.getName().matches(regex)) return ze; } return null; }
@Override public void closeExportWriter() { try { this.encrypter.close(); } catch (IOException ioe) { throw new RuntimeException(ioe); } } }
protected static void makeDir(String dirStr) { if(dirStr!=null) { makeDir(new File(dirStr)); } }
@Override public void closeImportReader() { try { this.decrypter.close(); } catch (Exception ioe) { throw new RuntimeException(ioe); } } }
/** * Zip + encrypt one "inFile" to one "outZipFile" using "password". */ public static void zipAndEncrypt(File inFile, File outFile, String password, AESEncrypter encrypter) throws IOException { AesZipFileEncrypter enc = new AesZipFileEncrypter(outFile,encrypter); try { enc.add(inFile, password); } finally { enc.close(); } }
/** * Encrypt all files from an existing zip to one new "zipOutFile" using "password". */ public static void zipAndEncryptAll(File inZipFile, File outFile, String password, AESEncrypter encrypter) throws IOException { AesZipFileEncrypter enc = new AesZipFileEncrypter(outFile,encrypter); try { enc.addAll(inZipFile, password); } finally { enc.close(); } }
/** * Add un-encrypted + un-zipped file to encrypted zip file.<br> * * @param file to add * @param pathForEntry to be used for addition of the file (path within zip file) * @param password to be used for encryption */ public void add(File file, String pathForEntry, String password) throws IOException, UnsupportedEncodingException { FileInputStream fis = new FileInputStream(file); try { add(pathForEntry, fis, password); } finally { fis.close(); } }
public ExtZipEntry getEntry( String name ) throws IOException, ZipException, DataFormatException { for( ExtZipEntry zipEntry : getEntryList() ) { if( name.equals(zipEntry.getName()) ) { return zipEntry; } } return null; }
public AesZipFileDecrypter( File zipFile, AESDecrypter decrypter ) throws IOException { this.zipFile = zipFile; this.decrypter = decrypter; this.raFile = new ExtRandomAccessFile( zipFile ); initDirOffsetPosAndComment(); }
protected static void makeDir(File dir) { if( dir!=null ) { if( !dir.exists() ) { if( dir.getParent()!=null ) { File parentDir = new File(dir.getParent()); if( !parentDir.exists() ) { makeDir(parentDir); } } dir.mkdir(); } } }
/** * Take all elements (files) from zip file and add them ENCRYPTED with password to the new zip * file created with this instance. <br> * Encrypted data of each file has the same size as the compressed data, though the file size is * increased by 26 bytes for salt and pw-verification bytes.<br> * While the {@link #add(File, String)} method does not need an additional zip file, this method * comes in handy, when your input data is larger than your available memory. * * @param pathToZipFile * provides zipFileEntries for encryption * @param password * used to perform the encryption * @throws IOException */ public void addAll(File pathToZipFile, String password) throws IOException { ZipFile zipFile = new ZipFile(pathToZipFile); try { add(zipFile, password); } finally { zipFile.close(); } }
public ExtZipEntry getEntry( String name ) throws IOException, ZipException, DataFormatException { for( ExtZipEntry zipEntry : getEntryList() ) { if( name.equals(zipEntry.getName()) ) { return zipEntry; } } return null; }
protected static void makeDir(File dir) { if( dir!=null ) { if( !dir.exists() ) { if( dir.getParent()!=null ) { File parentDir = new File(dir.getParent()); if( !parentDir.exists() ) { makeDir(parentDir); } } dir.mkdir(); } } }
/** * Take all elements (files) from zip file and add them ENCRYPTED with password to the new zip * file created with this instance. <br> * Encrypted data of each file has the same size as the compressed data, though the file size is * increased by 26 bytes for salt and pw-verification bytes.<br> * While the {@link #add(File, String)} method does not need an additional zip file, this method * comes in handy, when your input data is larger than your available memory. * * @param pathToZipFile * provides zipFileEntries for encryption * @param password * used to perform the encryption * @throws IOException */ public void addAll(File pathToZipFile, String password) throws IOException { ZipFile zipFile = new ZipFile(pathToZipFile); try { add(zipFile, password); } finally { zipFile.close(); } }
/** * Add un-encrypted + un-zipped file to encrypted zip file. * * @param file to add, provides the path of the file within the zip file via its getPath() * @param password to be used for encryption */ public void add(File file, String password) throws IOException, UnsupportedEncodingException { FileInputStream fis = new FileInputStream(file); try { add(file.getPath(), fis, password); } finally { fis.close(); } }
/** * Add un-encrypted + un-zipped file to encrypted zip file. * * @param file to add, provides the path of the file within the zip file via its getPath() * @param password to be used for encryption */ public void add(File file, String password) throws IOException, UnsupportedEncodingException { FileInputStream fis = new FileInputStream(file); try { add(file.getPath(), fis, password); } finally { fis.close(); } }