位置: 编程技术 - 正文

android解压带密码的zip包(android解压app)

编辑:rootadmin

推荐整理分享android解压带密码的zip包(android解压app),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:安卓解压带密码的压缩包,安卓解压密码压缩包,android 解压,安卓解压密码压缩包,安卓密码解压软件,安卓解压带密码,安卓解压带密码的压缩包,安卓 解压密码,内容如对您有帮助,希望把文章链接给更多的朋友!

网上找到的资料,还没试过,谁要是试了回复下吧。

android解压带密码的zip包(android解压app)

原文出自: a recent “fun” project, I needed my application to be able to access password-protected zip files of a particular format. It was one of these features I thought will take me no time to implement. Anyway, to my surprise, neither JDK supports password-protected ZIP files, nor I was able to find a suitable Java open source library I could use for that purpose. So, I ended up writing the utility class on my own. I wrote an implementation ofjava.io.InputStream that filters the ZIP file data and turns a password-protected ZIP into an unprotected one on the fly – so the stream can be nicely chained withjava.util.zip.ZipInputStream. Although the class is specifically targeted at the particular type of ZIP files I had to deal with (see the limitations below), maybe other people have to deal with the same type of files, or this class can provide a good start for others to turn it into a utility that would work with any type of ZIP (maybe I will do it myself some day – for now I don’t have time).To implement this class I used the ZIP File Format Specification as the source of information. I also used the 7-zip project (C&#;&#;) as a reference during the debugging to verify my understanding of the ZIP spec. and the CRC algorithm.So, here is the class:

?import java.io.IOException;import java.io.InputStream; public class ZipDecryptInputStream extendsInputStream { privatestatic final int[] CRC_TABLE = newint[]; // compute the table // (could also have it pre-computed - static{ for(int i = 0; i < ; i&#;&#;) { intr = i; for(int j = 0; j < 8; j&#;&#;) { if((r & 1) ==1) { r = (r >>>1) ^ 0xedb; }else { r >>>=1; } } CRC_TABLE[i] = r; } } privatestatic final int DECRYPT_HEADER_SIZE = ; privatestatic final int[] LFH_SIGNATURE = {0x,0x4b, 0x,0x}; privatefinal InputStream delegate; privatefinal String password; privatefinal int keys[] = new int[3]; privateState state = State.SIGNATURE; privateint skipBytes; privateint compressedSize; privateint value; privateint valuePos; privateint valueInc; publicZipDecryptInputStream(InputStream stream, String password) { this.delegate = stream; this.password = password; } @Override publicint read() throwsIOException { intresult = delegate.read(); if(skipBytes == 0) { switch(state) { caseSIGNATURE: if(result != LFH_SIGNATURE[valuePos]) { state = State.TAIL; }else { valuePos&#;&#;; if(valuePos >= LFH_SIGNATURE.length) { skipBytes =2; state = State.FLAGS; } } break; caseFLAGS: if((result & 1) ==0) { thrownew IllegalStateException("ZIP not password protected."); } if((result & ) ==) { thrownew IllegalStateException("Strong encryption used."); } if((result & 8) ==8) { thrownew IllegalStateException("Unsupported ZIP format."); } result -=1; compressedSize =0; valuePos =0; valueInc = DECRYPT_HEADER_SIZE; state = State.COMPRESSED_SIZE; skipBytes =; break; caseCOMPRESSED_SIZE: compressedSize &#;= result << (8* valuePos); result -= valueInc; if(result < 0) { valueInc =1; result &#;=; }else { valueInc =0; } valuePos&#;&#;; if(valuePos > 3) { valuePos =0; value =0; state = State.FN_LENGTH; skipBytes =4; } break; caseFN_LENGTH: caseEF_LENGTH: value &#;= result <<8 * valuePos; if(valuePos == 1) { valuePos =0; if(state == State.FN_LENGTH) { state = State.EF_LENGTH; }else { state = State.HEADER; skipBytes = value; } }else { valuePos =1; } break; caseHEADER: initKeys(password); for(int i = 0; i < DECRYPT_HEADER_SIZE; i&#;&#;) { updateKeys((byte) (result ^ decryptByte())); result = delegate.read(); } compressedSize -= DECRYPT_HEADER_SIZE; state = State.DATA; // intentionally no break caseDATA: result = (result ^ decryptByte()) &0xff; updateKeys((byte) result); compressedSize--; if(compressedSize == 0) { valuePos =0; state = State.SIGNATURE; } break; caseTAIL: // do nothing } }else { skipBytes--; } returnresult; } @Override publicvoid close() throwsIOException { delegate.close(); super.close(); } privatevoid initKeys(String password) { keys[0] =; keys[1] =; keys[2] =; for(int i = 0; i < password.length(); i&#;&#;) { updateKeys((byte) (password.charAt(i) &0xff)); } } privatevoid updateKeys(bytecharAt) { keys[0] = crc(keys[0], charAt); keys[1] &#;= keys[0] &0xff; keys[1] = keys[1] * &#; 1; keys[2] = crc(keys[2], (byte) (keys[1] >>)); } privatebyte decryptByte() { inttemp = keys[2] |2; return(byte) ((temp * (temp ^1)) >>> 8); } privateint crc(intoldCrc, byte charAt) { return((oldCrc >>> 8) ^ CRC_TABLE[(oldCrc ^ charAt) &0xff]); } privatestatic enum State { SIGNATURE, FLAGS, COMPRESSED_SIZE, FN_LENGTH, EF_LENGTH, HEADER, DATA, TAIL }}

These are the limitations:

Only the “Traditional PKWARE Encryption” is supported (spec. section VII)Files that have the “compressed length” information at the end of the data section (rather than at the beginning) are not supported (see “general purpose bit flag”, bit 3 in section V, subsection J in the spec.)

And this is how you can use it in your code:

?import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.IOException;import java.util.zip.ZipEntry;import java.util.zip.ZipInputStream; // usage: java Main [filename] [password]public class Main { publicstatic void main(String[] args) throws IOException { // password-protected zip file I need to read FileInputStream fis =new FileInputStream(args[0]); // wrap it in the decrypt stream ZipDecryptInputStream zdis =new ZipDecryptInputStream(fis, args[1]); // wrap the decrypt stream by the ZIP input stream ZipInputStream zis =new ZipInputStream(zdis); // read all the zip entries and save them as files ZipEntry ze; while((ze = zis.getNextEntry()) != null) { FileOutputStream fos =new FileOutputStream(ze.getName()); intb; while((b = zis.read()) != -1) { fos.write(b); } fos.close(); zis.closeEntry(); } zis.close(); }}Previous Entry: Jersey Hands-On LabNext Entry: Jersey and Cross-Site Request Forgery (CSRF)

Android中的轮播图 刚忙完了公司的项目,总算有些时间了,所以自己模仿公司的项目做了一些小demo,以后用。轮播图的效果,在Android的项目当中是比较常见的,其实现原

NUPT_移动应用开发 课程性质:本课程为南邮计算机科学与技术限选课,学分:2。学习回顾:主要分为四次大课,都在星期六。老师上课主要是以导论的形式对android开发进

使用开源库RoundedImageView 创建圆角ImageView以及引用时遇到的问题 转载请标明出处:

标签: android解压app

本文链接地址:https://www.jiuchutong.com/biancheng/386080.html 转载请保留说明!

上一篇:Android 开发中的零散知识点(Android开发中的几种管理机制的使用场景是什么)

下一篇:Android中的轮播图(android 轮播)

  • 未交增值税和应交增值税科目怎么调整
  • 捐赠免税会计分录
  • 抄税报税流程图片
  • 亏损属于什么科目
  • 工会经费支付福利方案
  • 税金及附加与应交税费的差额
  • 新成立的公司企业所得税怎么申报
  • 企业所得税1季度申报季初从业人数个税所属期12月
  • 集装箱维护是做什么的
  • 小规模纳税人不开票收入怎么报税
  • 跨年度项目预算怎么安排
  • 税收优惠形式包括
  • 空白增值税报表在哪下载
  • 酒店怎么合理规划管理
  • 营改增租金收入税率
  • 拿到一个材料如何加工
  • 简易计税的应交所得税
  • 企业的福利费如何使用
  • 装卸费收取的税收筹划是怎样的?
  • 合同到期退房子,租金退吗
  • 损益类科目的借方表示
  • 调减管理费用如何调整本年利润
  • 应交税费有余额怎么结转
  • 政府性基金收入来源三种
  • 盈亏余额
  • bios屏蔽接口
  • php中class用法
  • 冲回上年多提的费用会计分录
  • phpwhile用法
  • js身份证正则验证
  • 税收协定与国内税法发生冲突
  • 编制记账凭证出现错误
  • 一借多贷的会计分录格式
  • uniapp下拉菜单
  • php单例模式连接数据库
  • php url函数
  • 人工智能大模型体验报告3.0
  • admit允许
  • 微信收款怎么做会计分录
  • gin框架使用案例
  • 其他权益工具投资
  • 无租房合同可以贷款吗
  • 购买实验材料入什么科目
  • 一般纳税人承租个人房屋怎么抵扣
  • 赠送给客户的商品是否要计入费用?
  • 包装就是包装物
  • 企业当期营业收入的计算
  • 经营性现金净流量公式
  • 烈士祭扫仪式
  • 其他综合收益转到留存收益
  • 不开票销售收入怎么做账务处理
  • 预付工程款该怎么记账
  • 免税的会计分录有哪些
  • 税务局代开的增值税专票可以红冲吗?
  • 桩基检测费一定要收吗
  • 预收账款变成了什么
  • 营业外支出的用法
  • 工程结算的会计分录怎么做
  • windows10x预览版
  • 2008r2数据库备份
  • 误删了分区怎么恢复
  • 使用windows防火墙禁止软件联网
  • service5.exe - service5是什么进程 有什么用
  • linux中sudoers
  • Basic Layout——基本布局
  • node session
  • android中的布局分为6种,分别是
  • Android自定义对话框
  • perl获取文件名
  • autorun病毒怎么清理
  • jquery.handleerror
  • 物理引擎演示
  • js实现功能
  • shell脚本语句
  • Unity3D游戏开发标准教程
  • 安装了python2.7和3.6怎么切换版本
  • 怎么撤销税务三方协议
  • 餐饮发票真伪查询系统
  • 三证合一后还要做什么
  • 86年的2020年是多少岁
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设