⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 watch.java

📁 AES加密软件。java实现。可以加密
💻 JAVA
字号:
import java.awt.*;

import javax.swing.*;

import java.awt.event.*;
public class Watch extends JFrame implements ActionListener{
	JButton btjiami=new JButton("加密文件");
	JButton btjiemi=new JButton("解密文件");
	JButton btfile=new JButton("选择文件");
	JButton num1=new JButton("第一轮");
	JButton num2=new JButton("第二轮");
	JButton num3=new JButton("第三轮");
	JButton num4=new JButton("第四轮");
	JButton num5=new JButton("第五轮");
	JButton num6=new JButton("第六轮");
	JButton num7=new JButton("第七轮");
	JButton num8=new JButton("第八轮");
	JButton num9=new JButton("第九轮");
	JButton num10=new JButton("第十轮");
	JButton btkey=new JButton("  扩展密钥  ");
	JLabel lbpm=new JLabel("                       请在下面选择要观察的结果");
	JLabel lbnotice=new JLabel(" 注意:每次加密文件或解密文件之前请先选择文件");
	JTextArea result = new JTextArea(5,35); 
	JScrollPane sresult = new JScrollPane(result);
	static String cfile = "";
	static int work = 0;
	Box b;
	public Watch()
	{
		super("AES");
		Container c=getContentPane();
		c.setLayout(null);
		btjiami.setBounds(20, 20, 100, 20);
		btjiemi.setBounds(140, 20, 100, 20);
		btfile.setBounds(260, 20, 100, 20);
		c.add(btjiami);
		c.add(btjiemi);
		c.add(btfile);
		//c.add(btfile);
		JPanel pm=new JPanel();
		pm.setLayout(null);
		pm.setBounds(0, 50, 400, 20);
		pm.setBackground(Color.yellow);
		lbpm.setBounds(0, 0, 400, 20);
		pm.add(lbpm);
		c.add(pm);
		sresult.setBounds(10, 80, 370, 200);
		c.add(sresult);
		
		num1.setBounds(10,300,80,20);
		c.add(num1);
		num2.setBounds(110,300,80,20);
		c.add(num2);
		num3.setBounds(210,300,80,20);
		c.add(num3);
		num4.setBounds(310,300,80,20);
		c.add(num4);
		
		num5.setBounds(10,330,80,20);
		c.add(num5);
		num6.setBounds(110,330,80,20);
		c.add(num6);
		num7.setBounds(210,330,80,20);
		c.add(num7);
		num8.setBounds(310,330,80,20);
		c.add(num8);
		
		num9.setBounds(10,360,80,20);
		c.add(num9);
		num10.setBounds(110,360,80,20);
		c.add(num10);
		btkey.setBounds(210,360,180,20);
		c.add(btkey);
		lbnotice.setBounds(0,400,400,20);
		c.add(lbnotice);
		
		btjiami.addActionListener(this);
		btjiemi.addActionListener(this);
		btfile.addActionListener(this);
		btkey.addActionListener(this);
		num1.addActionListener(this);
		num2.addActionListener(this);
		num3.addActionListener(this);
		num4.addActionListener(this);
		num5.addActionListener(this);
		num6.addActionListener(this);
		num7.addActionListener(this);
		num8.addActionListener(this);
		num9.addActionListener(this);
		num10.addActionListener(this);
		setSize(400,450);
		setResizable(false);
		setVisible(true);
	}
	
	public void actionPerformed(ActionEvent e)
	{
		
		String keyfile = "key.dat";

		if(e.getSource()==btfile)
		{
		      b = new Box();
		}
		else if(e.getSource()==btjiami)
		{
			AES.run(cfile,keyfile);
			JOptionPane.showMessageDialog(this.getParent(), "finish computing.");
			work = 1;
		}
		else if(e.getSource()==btjiemi)
		{
			AES.jiemi(cfile,keyfile);
			JOptionPane.showMessageDialog(this.getParent(), "finish computing.");
			work = 1;
		}
		
		else if(e.getSource()==btkey)
		{
			AES.extendkeys(keyfile);
			char [] key = new char[396];
			int k = 0;
			for(int i=0;i<44;i++)
			  {
				  for(int j=0;j<8;j++,k++)
				        key[k] = AES.w[i][j];
				  if((i+1)%4==0)
				  {
					  key[k] = '\n';
					  k++;
				  }
				  else
				  {
					  key[k] = ' ';
					  k++;
				  }
			  }
			String skey = String.copyValueOf(key);
			result.setText(skey);
		}
		else if(e.getSource()==num1)
		{
			if(work==0)
				JOptionPane.showMessageDialog(this.getParent(), "请先选择文件加密或解密.");
			else{
				String lun1 = String.copyValueOf(AES.lun[0]);
				result.setText(lun1);
			}
		}
		else if(e.getSource()==num2)
		{
			if(work==0)
				JOptionPane.showMessageDialog(this.getParent(), "请先选择文件加密或解密.");
			else{
				String lun1 = String.copyValueOf(AES.lun[1]);
				result.setText(lun1);
			}
		}
		else if(e.getSource()==num3)
		{
			if(work==0)
				JOptionPane.showMessageDialog(this.getParent(), "请先选择文件加密或解密.");
			String lun1 = String.copyValueOf(AES.lun[2]);
			result.setText(lun1);
		}
		else if(e.getSource()==num4)
		{
			if(work==0)
				JOptionPane.showMessageDialog(this.getParent(), "请先选择文件加密或解密.");
			else{
				String lun1 = String.copyValueOf(AES.lun[3]);
				result.setText(lun1);
			}
		}
		else if(e.getSource()==num5)
		{
			if(work==0)
				JOptionPane.showMessageDialog(this.getParent(), "请先选择文件加密或解密.");
			else{
				String lun1 = String.copyValueOf(AES.lun[4]);
				result.setText(lun1);
			}
		}
		else if(e.getSource()==num6)
		{
			if(work==0)
				JOptionPane.showMessageDialog(this.getParent(), "请先选择文件加密或解密.");
			else{
				String lun1 = String.copyValueOf(AES.lun[5]);
				result.setText(lun1);
			}
		}
		else if(e.getSource()==num7)
		{
			if(work==0)
				JOptionPane.showMessageDialog(this.getParent(), "请先选择文件加密或解密.");
			else{
				String lun1 = String.copyValueOf(AES.lun[6]);
				result.setText(lun1);
			}
		}
		else if(e.getSource()==num8)
		{
			if(work==0)
				JOptionPane.showMessageDialog(this.getParent(), "请先选择文件加密或解密.");
			else{
				String lun1 = String.copyValueOf(AES.lun[7]);
				result.setText(lun1);
			}
		}
		else if(e.getSource()==num9)
		{
			if(work==0)
				JOptionPane.showMessageDialog(this.getParent(), "请先选择文件加密或解密.");
			else{
				String lun1 = String.copyValueOf(AES.lun[8]);
				result.setText(lun1);
			}
		}
		else if(e.getSource()==num10)
		{
			if(work==0)
				JOptionPane.showMessageDialog(this.getParent(), "请先选择文件加密或解密.");
			else{
				String lun1 = String.copyValueOf(AES.lun[9]);
				result.setText(lun1);
			}
		}
		result.setVisible(true);
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Watch();
	}

}
class Box extends JFrame implements ActionListener{
	JTextField way = new JTextField();
	JTextField name = new JTextField();
	JLabel   bway = new JLabel("文件路径 : ");
	JLabel   bname = new JLabel("文件名 : ");
	JTextField hway = new JTextField();
	JTextField hname = new JTextField();
	JLabel   hbway = new JLabel("处理后文件路径:");
	JLabel   hbname = new JLabel("处理后文件名:");
	JButton ok = new JButton("OK");

	public Box()
	{
		super("open file");
		Container c=getContentPane();
		c.setLayout(null);
		bway.setBounds(20, 20, 80, 20);
		c.add(bway);
		way.setBounds(110, 20, 200, 20);
		c.add(way);
		bname.setBounds(20, 50, 80, 20);
		c.add(bname);
		name.setBounds(110, 50, 200, 20);
		c.add(name);
		
		hbway.setBounds(20, 80, 80, 20);
		c.add(hbway);
		hway.setBounds(110, 80, 200, 20);
		c.add(hway);
		hbname.setBounds(20, 110, 80, 20);
		c.add(hbname);
		hname.setBounds(110, 110, 200, 20);
		c.add(hname);
		ok.setBounds(140, 150, 80, 20);
		c.add(ok);
		ok.addActionListener(this);
		
		setSize(400,300);
		setResizable(false);
		setVisible(true);
	}

	public void actionPerformed(ActionEvent e)
	{
		Watch.cfile =way.getText()+"\\"+name.getText();
		AES.ff =hway.getText()+"\\"+hname.getText();
		JOptionPane.showMessageDialog(this.getParent(), Watch.cfile+" to "+AES.ff);
		this.dispose();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -