位置: 编程技术 - 正文

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 轮播)

  • 外地预缴的附加税怎么算
  • 一般纳税人购买二手车可以抵扣嘛
  • 开具电费发票如何入账?
  • 结构性存款现金流量表如何分类
  • 公司减免社保到几月份
  • 电子税务局怎么删除办税员
  • 出口报关单运费小于实际运费
  • 没有以前年度损益调整这个科目,怎么增加?
  • 预售收入是否可以退税
  • 新征用的耕地是什么意思
  • 工程管理费如何使用
  • 汽车行业保险丝
  • 支付宝企业账户客服电话
  • 跨年度销售退回所得税
  • 如何查询增值税申报表
  • 收到的借款利息计入什么科目
  • 一般纳税人年度开票限额
  • 小微企业免征税额
  • 工会经费具体用途是什么
  • 发票连号不许报销吗
  • 资产类科目包括哪些内容
  • 固定资产投资方案
  • 未开票的销售要交增值税吗
  • 金融企业贷款损失税前扣除
  • 损益类账户包括成本类吗
  • 资产负债率高说明长期偿债能力强吗
  • 民办学校会计分录 百度网盘
  • 升级win10到专业版
  • apple mac 系统
  • 产品入库的业务流程
  • 房地产开发有限公司英文
  • 客户罚款记哪个科目
  • 经营出租固定资产折旧额计入什么科目
  • win10电脑声道怎么设置
  • iis配置mime
  • thinkphp5控制器
  • 招待费的范畴
  • windows默认网关应该设置为的地址
  • 政府补助的会计处理分录
  • 如何做好零售商
  • 事业单位接受捐赠固定资产入账
  • 前端布局flex
  • php实现多维数组输入
  • 滚动条基本样式有哪些
  • AIGC之GPT-4:GPT-4的简介(核心原理/意义/亮点/技术点/缺点/使用建议)、使用方法、案例应用(计算能力/代码能力/看图能力等)之详细攻略
  • thinkphp模糊查询
  • 缴纳残保金会计分录最新
  • 员工业余自学
  • 公司借调员工
  • 即征即退实际退税额35栏可以不填吗
  • 打车费的会计分录
  • 采购的技术服务费会计分录
  • 无法收回的房租押金出什么会计科目
  • 当期可抵扣进项税额包括进项转出额吗
  • 余额百分比法计提坏账准备
  • 深入分析的成语
  • 个体工商户是否属于企业
  • 考证交社保是怎么回事
  • 联通里的话费可以拿来干嘛
  • 无形资产如何摊销 当月还是下月
  • 应收应付抹零账务处理
  • 增值税专用发票金额与付款金额是否必须一致
  • 劳务费无发票怎么处理
  • 电商的成本构成包括
  • 企业所得税季报与年报的关系
  • 本月应付电费计入哪个账户
  • 子公司如何向母公司开户
  • 生育津贴领取条件及流程
  • 一般性企业
  • 企业收到的应收票据应按什么作为入账金额
  • supervisor.sock refused connection
  • linux检查文件内容
  • xp桌面浏览器图标不见了
  • win7安全更新kb4534314
  • linux tar命令安装
  • nodejs 异步io
  • sudo提权漏洞
  • 党建工作领导小组会议
  • 个人出租平台有哪些
  • 企业年检里的纳税是什么
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设