怎样实现linux下c/c++对文件加密压缩成zip文件

sinat_18880787 2016-05-19 07:28:22
想实现在linux下用c/c++把文件压缩加密的成zip文件,在windows 上能用普通的解压软件解密解压,zlib这个库好像不支持加密了
...全文
1955 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
sinat_18880787 2016-05-30
  • 打赏
  • 举报
回复
最终用zlib库实现了,zlib库有个自带的minizip。给后人踩坑
sinat_18880787 2016-05-24
  • 打赏
  • 举报
回复
引用 6 楼 sinat_18880787 的回复:
[quote=引用 5 楼 anniue 的回复:] struct zip *za; struct zip_file *zf; struct zip_stat sb; char buf[100]; long long sum; int len; int test; int err; int fd; za = zip_open("/home/alex/Documents/Teste_Libzip.zip", 0, &err); if (!za) { return 1; } zip_set_default_password(za, "xxx"); zf = zip_fopen(za, "remote_access_aaa.txt", ZIP_FL_ENCRYPTED); if (!zf) { return 3; } len = zip_fread(zf, buf, 100);
你的接口在哪里的呀?[/quote] The zip_set_default_password() function sets the default password used when accessing encrypted files. If password is NULL, the default password is unset. If you prefer a different password for single files, use zip_fopen_encrypted(3) instead of zip_fopen(3). Usually, however, the same password is used for every file in an zip archive. 这是解密的,没有加密的接口
sinat_18880787 2016-05-23
  • 打赏
  • 举报
回复
引用 5 楼 anniue 的回复:
struct zip *za; struct zip_file *zf; struct zip_stat sb; char buf[100]; long long sum; int len; int test; int err; int fd; za = zip_open("/home/alex/Documents/Teste_Libzip.zip", 0, &err); if (!za) { return 1; } zip_set_default_password(za, "xxx"); zf = zip_fopen(za, "remote_access_aaa.txt", ZIP_FL_ENCRYPTED); if (!zf) { return 3; } len = zip_fread(zf, buf, 100);
你的接口在哪里的呀?
anniue 2016-05-22
  • 打赏
  • 举报
回复
struct zip *za; struct zip_file *zf; struct zip_stat sb; char buf[100]; long long sum; int len; int test; int err; int fd; za = zip_open("/home/alex/Documents/Teste_Libzip.zip", 0, &err); if (!za) { return 1; } zip_set_default_password(za, "xxx"); zf = zip_fopen(za, "remote_access_aaa.txt", ZIP_FL_ENCRYPTED); if (!zf) { return 3; } len = zip_fread(zf, buf, 100);
anniue 2016-05-22
  • 打赏
  • 举报
回复
楼主既然用zip 压缩,那么就应该使用zip的lib库, 官网 http://freecode.com/projects/libzip 在这个上面有源代码, 有帮助文档, 看看帮助文档,肯定有相关的API,用API就能完成加解密了。
renwotao2009 2016-05-20
  • 打赏
  • 举报
回复
引用 2 楼 sinat_18880787 的回复:
[quote=引用 1 楼 renwotao2009 的回复:] 去官网了解下
那个官网,zip?[/quote]http://www.zlib.net/
sinat_18880787 2016-05-20
  • 打赏
  • 举报
回复
引用 1 楼 renwotao2009 的回复:
去官网了解下
那个官网,zip?
renwotao2009 2016-05-20
  • 打赏
  • 举报
回复
去官网了解下

23,120

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧