如何创建普通的受密码保护的 ZIP 存档?

发布于 2024-12-09 22:47:13 字数 475 浏览 1 评论 0原文

我的应用程序压缩多个文件,将 zip 文件保存到 SD 卡,然后通过电子邮件将 zip 文件发送到某个地址。

压缩是通过以下代码完成的:使用 Android 压缩文件(以编程方式)

现在的问题是,如何在 zip 文件上设置密码,以便授权人员在计算机(Windows、Mac 或 Ubuntu)上打开该文件时能够使用提供的密码提取文件?

我读了这篇文章:Android zip 文件身份验证,但在我看来,读取 zip用另一部手机完成了...还是我错了? 如果有人知道请告诉我!谢谢!

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!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏日浅笑〃 2024-12-16 22:47:13

我搜索了很多,终于找到了一个好的库,可以使用密码压缩文件easy:

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);

这个库的文档已经足够好了,我只是从那里添加了一些示例。
它是完全免费的,并且是专门为 Android 编写的。
Mvn 链接

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.
Mvn Link

神魇的王 2024-12-16 22:47:13

由于Android有一个JVM,您可以尝试使用您在java中看到的所有库(有些可以运行,有些不能,并且某些库的一些更改也可以)。

这样我就会复制这个回答问题(用 Java 编写受密码保护的 Zip 文件):

经过多次搜索,我发现了三种方法:

一组免费提供的源代码,适用于单个文件 zip。
但是,没有许可证。用法是
AesZipOutputStream.zipAndEcrypt(...)。
http://merkert.de/de/info/zipaes/src.zip
( https://forums.oracle.com/forums/thread.jspa?threadID =1526137

更新:此代码现已获得 Apache 许可并发布于
http://code.google.com/p/winzipaes/ 。它对我有用(一个文件
zip),并很好地填补了 Java 开源库中的一个漏洞。

商业产品(撰写本文时价格为 500 美元)。我无法验证是否
这是有效的,因为他们的试用许可证方法很复杂。它也是一个
移植的 .NET 应用程序: http://www.nsoftware.com/ipworks/zip/default .aspx

商业产品(撰写本文时为 290 美元)。仅适用于
Wnidows,因为它使用 dll: http://www.example-code.com/java /zip.asp

您还必须知道,也许将它们适应 Android 并不容易,但也许您很幸运,其中一些将立即为您运行

祝你好运!

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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文