How to pin a password file (AES) for iOS and Android?

Is there a library that can encrypt a file with a password using AES encryption?

This is discovered for iOS: https://github.com/gianlucabertani/Objective-Zip

+6
source share
4 answers

UPDATE:

Updated password setting in the parameters and method of creating a zipfile.

You can use the Zip4j library http://www.lingala.net/zip4j/download.php

if you want to use AES Encryption, you can also use the following code

// Initiate ZipFile object with the path/name of the zip file. ZipFile zipFile = new ZipFile("c:\\ZipTest\\AddFilesWithAESZipEncryption.zip"); // Build the list of files to be added in the array list // Objects of type File have to be added to the ArrayList ArrayList filesToAdd = new ArrayList(); filesToAdd.add(new File("c:\\ZipTest\\sample.txt")); filesToAdd.add(new File("c:\\ZipTest\\myvideo.avi")); filesToAdd.add(new File("c:\\ZipTest\\mysong.mp3")); // Initiate Zip Parameters which define various properties ZipParameters parameters = new ZipParameters(); parameters.setCompressionMethod(Zip4jConstants.COMP_DEFLATE); // set compression method to deflate compression //DEFLATE_LEVEL_FASTEST - Lowest compression level but higher speed of compression //DEFLATE_LEVEL_FAST - Low compression level but higher speed of compression //DEFLATE_LEVEL_NORMAL - Optimal balance between compression level/speed //DEFLATE_LEVEL_MAXIMUM - High compression level with a compromise of speed //DEFLATE_LEVEL_ULTRA - Highest compression level but low speed parameters.setCompressionLevel(Zip4jConstants.DEFLATE_LEVEL_NORMAL); //Set the encryption flag to true parameters.setEncryptFiles(true); //Set the encryption method to AES Zip Encryption parameters.setEncryptionMethod(Zip4jConstants.ENC_METHOD_AES); //AES_STRENGTH_128 - For both encryption and decryption //AES_STRENGTH_192 - For decryption only //AES_STRENGTH_256 - For both encryption and decryption //Key strength 192 cannot be used for encryption. But if a zip file already has a //file encrypted with key strength of 192, then Zip4j can decrypt this file parameters.setAesKeyStrength(Zip4jConstants.AES_STRENGTH_256); //set password parameters.setPassword("your password here"); // Now add files to the zip file // Note: To add a single file, the method addFile can be used // Note: If the zip file already exists and if this zip file is a split file // then this method throws an exception as Zip Format Specification does not // allow updating split zip files zipFile.addFiles(filesToAdd, parameters); 

setEncryptionMethod () sets the types for the required encryption. and setAesKeyStrength () sets the strength of the encryption algorithm.

+5
source

For Android, there is a good blog entry for unpacking files here: http://blog.alutam.com/2009/10/31/reading-password-protected-zip-files-in-java/ This is implemented using 7-zip- standards (actually the old form of pkware zip, not AES), so you can unzip files created from other platforms, as well

However, I prefer to use this: zip4j , because it already has java libs, and you can just integrate them into your Android project, and since integrating it into JAVA libraries is quite simple, you get a quick quick fix. Moreover, since it supports AES, this is more relevant for your question.

Edit: My friend uses Minizip for iOS to implement zipping / unzipping for his iOS project. You can try this

FYI: We could not get zip4j and Minizip to interact with each other when we used passwords (zip archive in Andropid, and unzip it in iOS and vice versa) (we tried to read your message, so we have spent a bit of time so far ) If you try them and take a step forward in this direction, send a message here.

+1
source

You can use OpenSSL for android https://github.com/eighthave/openssl-android requires some knowledge in the NDK to compile the library to render it (.so), it is very perfermant to use a native library like open ssl to win some perfermancy

+1
source

Try using the libzip library. This is a C library and there is an Android NDK package , so you can reuse it on iOS and Android

0
source

All Articles