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