How to create a normal password

My app zips several files, saves the zip file to the SD card, and it emails the zip file to an address.

The zipping is done with this code: Zipping Files with Android (Programmatically).

Now the question is, how do I put a password on the zip file so that authorized individuals who opens it on a computer (Windows, Mac, or Ubuntu) would be able to extract the files with a supplied password?

I read this post: Android zip file authentication, but it sounds to me that reading of the zip is done with another phone... or am I wrong? If anybody knows please let me know! Thanks!


since Android has a JVM , you can try to use all lib that you see for java (some will run , some not , and some changes of some library will be ok too) .

This way i'll copy past this answer fo the question (Write a password protected Zip file in Java):

After much searching, I've found three approaches:

A freely available set of source code, suitable for a single file zip. However, there is no license. Usage is AesZipOutputStream.zipAndEcrypt(...). http://merkert.de/de/info/zipaes/src.zip ( https://forums.oracle.com/forums/thread.jspa?threadID=1526137 )

UPDATE: This code is now Apache licensed and released at http://code.google.com/p/winzipaes/ . It worked for me (one file in the zip), and fills a hole in Java's opens source libraries nicely.

A commercial product ($500 at the time of writing). I can't verify if this works, as their trial license approach is complex. Its also a ported .NET app: http://www.nsoftware.com/ipworks/zip/default.aspx

A commercial product ($290 at the time of writing). Suitable only for Wnidows as it uses a dll: http://www.example-code.com/java/zip.asp

You must also know that maybe it won't be easy to adapt them to Android , but maybe you are lucky and some of this will run for you immediately .

Good luck!


I've searched a lot and finally found a good library that can zip files with password easily:

Zip:

ZipArchive zipArchive = new ZipArchive();
zipArchive.zip(targetPath,destinationPath,password);

Unzip:

ZipArchive zipArchive = new ZipArchive();
zipArchive.unzip(targetPath,destinationPath,password);

Rar:

RarArchive rarArchive = new RarArchive();
rarArchive.extractArchive(file archive, file destination);

The documentation of this library is good enough, I just added a few examples from there. It's totally free and wrote specially for android.

链接地址: http://www.djcxy.com/p/9786.html

上一篇: 混合模式项目的内存泄漏检测:托管,非托管和本机

下一篇: 如何创建一个正常的密码