文件的加密解密程序

这个Java程序实现了文件的加密和解密功能,采用DES算法,并使用CBC模式和PKCS5Padding填充方式。程序包括四个核心部分:密码Hash值生成、密钥生成、文件加密和文件解密。在主界面中,通过按钮触发加密和解密操作,通过用户的密码生成加密密钥,并对文件进行加解密处理。
摘要由CSDN通过智能技术生成

Public class JCEDialog extends JDialog//文件加密解密窗口类

Final int MAX_BUF_SIZE=1024;
String Algorithm=”DES”;
String EncryptMode=”CBC”;
String PaddingScheme=”PKCS5Padding”

Import Shares.* Public byet[] HashDigest(String StrPassword)//Shares包,HashDigest类,密码Hash值生成方法

Import SecretKey.* Public SecretKey GenerateKey(byte[] KeyData)//SecreKey包,GenerateKey类,由密码Hash值生成秘密密钥方法

Import EncAndDec.* Public boolen EncryptFile(SecretKey SecKey1,String PlainFilePath1,String CipherFilePath1)// EncAndDec包,Enc类,文件加密方法

Import EnAndDec.* Public boolen DecryptFile(SecretKey SecKey2,String PlainFilePath2,String CipherFilePath2)// EncAndDec包,Dec类,文件解密方法

public static void main (String[] args)//窗口类主方法体

btnEncrypt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e){}
}//加密按钮事件

btnDecrypt.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {}
}//解密按钮事件

程序的主要代码:
主界面模块主要代码JCEDialog.java
//加密按钮事件的处理方法
btnEncrypt.addActionListener(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=txtPl

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值