ImageVerifierCode 换一换
格式:DOCX , 页数:15 ,大小:284.84KB ,
资源ID:14367339      下载积分:5 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bingdoc.com/d-14367339.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(文件加密与解密Java课程设计报告.docx)为本站会员(b****5)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

文件加密与解密Java课程设计报告.docx

1、文件加密与解密Java课程设计报告JAVA课程设计 题目: 文件的加密与解密 姓 名: 学 号: 班 级: 日 期: 指导老师分 数一、 设计思路自从Java技术出现以业,有关Java平台的安全性用由Java技术发展所引发的安全性问题,引起了越来越多的关注。目前,Java已经大量应用于各个领域,研究Java的安全性对于更好地利用Java具有深远的意义。使用Java的安全机制设计和实现安全系统更具有重要的应用价值。本课程设计,主要实践Java安全中的JCE模块,包括密钥生成,Cipher对象初始化、加密模式、填充模式、底层算法参数传递,也涉及文件读写与对象输入输出流。二、具体实现本系统通过用户界

2、面接收三个参数:明文文件、密文文件、口令。采用DES加密算法,密码分组链(Cipher Block Chaining,CBC)加密模式,PKCS#5-Padding的分组填充算法。因为CBC涉及到底层算法参数的解密密钥的传递,所以将明文文件中的字节块以密封对象(Sealed Object)的方式加密后,用对象流输出到密文文件,这样就将密文、算法参数、解密密钥三都密封到一个对象中了。口令的hash值作为产生密钥的参数。设计流程图如下所示:文件加密与解密设计流程图本系统中,包含Default,Shares,SecretKey,EncAndDec四个包共6个类组成。定义的几个 参数:MAX_BUF_

3、SIZE为每次从文件中读取的字节数,也是内存缓冲区的大小;加密算法为DES;加密模式是密码分组链(CBC)模式;分组填充方式是PKCS#5Padding。包和类结构图如下所示:本课程设计,包和类结构图:Package Default - Class JCEDialog1) 1) Public byet HashDigest(String StrPassword) Public SecretKey GenerateKey(byte KeyData) Public boolen EncryptFile(SecretKey SecKey1,String PlainFilePath1,String C

4、ipherFilePath1) Public boolen DecryptFile(SecretKey SecKey2,String PlainFilePath2,String CipherFilePath2)ava项目设计与开发范例.北京.电子工业出版社,2朱福喜,尹为民等编著.Java语言与面向对象程序设计.武汉:武汉大学出版社, 3冯军,程超等编著.JBuilder 程序设计.北京:中国水利水电出版社,4丁振凡,黎章等编著.Java语言实用教程.北京:北京邮电大学出版社,5何桥,李肃义等编著.Java程序设计简明教程.北京:中国水利水电出版社,六、附录程序的主要代码:主界面模块主要代码/

5、加密按钮事件的处理方法(new ActionListener() Override public void actionPerformed(ActionEvent e) HashDigest hashDigest=new HashDigest(); GenerateKey generateKey=new GenerateKey(); Enc enc=new Enc(); / TODO Auto-generated method stub String PlainFilePath1,CipherFilePath1,Strpasswrod1; PlainFilePath1=(); CipherFi

6、lePath1=(); /Strpasswrod1 = (); Strpasswrod1 = new String(); / byte KeyData1= (Strpasswrod1);/生成密码的HASH值 SecKey1=(KeyData1); /由输入的密码的hash值,产生加密密钥 boolean EncOK=(SecKey1, PlainFilePath1, CipherFilePath1);/调用文件加密算法 (); if(EncOK=true) (null, 文件加密成功!); else (null, 文件加密失败!); );/解密按钮事件的处理方法(new ActionList

7、ener() Override public void actionPerformed(ActionEvent e) / TODO Auto-generated method stub HashDigest hashDigest=new HashDigest(); GenerateKey generateKey=new GenerateKey(); Dec dec =new Dec(); String PlainFilePath2,CipherFilePath2,StrPasswrod2; PlainFilePath2=(); CipherFilePath2=(); /StrPasswrod2

8、=(); StrPasswrod2=new String(); byte KeyData2=(StrPasswrod2); SecKey2=(KeyData2); boolean DecOK=(SecKey2, PlainFilePath2, CipherFilePath2); (); if(DecOK=true) (null, 文件解密成功!); else (null, 文件解密失败!); );密码hash值生成 public class HashDigest public byte HashDigest(String StrPassword) byte BytePasswrod=(); S

9、tring DigestAlgorithm =SHA-1; byte KeyMaterial =; try MesDigest=(DigestAlgorithm); (BytePasswrod); KeyMaterial=(); return KeyMaterial; catch e1) (); return null; Hash产生密钥算法 public class GenerateKey public SecretKey GenerateKey(byte KeyData) String Alogorithm=DES; try DesKeySpec=new DESKeySpec(KeyDat

10、a); SecKeyFac=(Alogorithm); secKey=(DesKeySpec); return secKey; catch e1) (); return null; catch e2) (); return null; 文件加密算法 public class Enc final int MAX_BUF_SIZE=1024; String Algorithm=DES; String EncryptMode=CBC; String PaddingScheme=PKCS5Padding; public boolean EncryptFile(SecretKey SecKey1,Str

11、ing PlainFilePath1,String CipherFilePath1) try /加密,将明文文件加密到另一个文件 Cipher1 = (Algorithm + / + EncryptMode + / + PaddingScheme); ,SecKey1); PlainFile1=new File(PlainFilePath1); CipherFile1=new File(CipherFilePath1); long FileLen1=(); if(FileLen1=0) (null, 明文文件是空的!); return false; fis1=new FileInputStre

12、am(PlainFile1); fos1=new FileOutputStream(CipherFile1); ObjOS1=new ObjectOutputStream(fos1); byte buffer1 = new byteMAX_BUF_SIZE; int i=(buffer1); while(i!=-1) SealedObj1=new SealedObject(buffer1, Cipher1); (SealedObj1); i=(buffer1); (); (); (); (); return true; catch e1) (); return false; catch e2)

13、 (); return false; catch e3) (); return false; 文件解密算法 public class Dec final int MAX_BUF_SIZE=1024; public boolean DecryptFile(SecretKey SecKey2,String PlainFilePath2,String CipherFilePath2) try PlainFile2=new File(PlainFilePath2); CipherFile2=new File(CipherFilePath2); long FileLen2=(); if(FileLen2

14、=0) (null, 密文文件是空的!); return false; fis2=new FileInputStream(CipherFile2); ObjIS2=new ObjectInputStream(fis2); fos2=new FileOutputStream(PlainFile2); byte buffer2=new byteMAX_BUF_SIZE; SealedObj2=null; SealedObj2=(SealedObject)(); while(SealedObj2!=null) buffer2=(byte)(SecKey2); (buffer2); SealedObj2=(SealedObject)(); (); (); (); (); return true; catch e1) (); return false; catch e2) 解密完成!); return true; catch e3) (); return false;

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2