欢迎来到冰点文库! | 帮助中心 分享价值,成长自我!
冰点文库
全部分类
  • 临时分类>
  • IT计算机>
  • 经管营销>
  • 医药卫生>
  • 自然科学>
  • 农林牧渔>
  • 人文社科>
  • 工程科技>
  • PPT模板>
  • 求职职场>
  • 解决方案>
  • 总结汇报>
  • ImageVerifierCode 换一换
    首页 冰点文库 > 资源分类 > DOCX文档下载
    分享到微信 分享到微博 分享到QQ空间

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

    • 资源ID:14367339       资源大小:284.84KB        全文页数:15页
    • 资源格式: DOCX        下载积分:5金币
    快捷下载 游客一键下载
    账号登录下载
    微信登录下载
    三方登录下载: 微信开放平台登录 QQ登录
    二维码
    微信扫一扫登录
    下载资源需要5金币
    邮箱/手机:
    温馨提示:
    快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。
    如填写123,账号就是123,密码也是123。
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP,免费下载
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    文件加密与解密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;


    注意事项

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

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

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

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


    收起
    展开