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

📄 ui.java

📁 des的加密源码
💻 JAVA
字号:
import java.applet.Applet;
import java.awt.*;

public class UI extends Applet{
	
	Text text;
   
	//GUI组件
	private Label label1;
	private Label label2;
	private Label label3;
	private TextField textfield1;
	private TextField textfield2;
	private TextField textfield3;
	private Button button1;
	private Button button2;
	private Panel p;
	private Panel p1;
	private Panel p2;
    //初始化变量和组件
	public void init(){
		
        label1=new Label("    明文");
		label2=new Label("    密码");
		label3=new Label("    密文");
        textfield1=new TextField("请输入明文长度为4");
		textfield2=new TextField("请输入密文长度为4");
		textfield3=new TextField(4);
	    button1=new Button("加密");
		button2=new Button("解密");
		
		
		p=new Panel();
		p.setBackground(Color.gray);
		p1=new Panel();
	    p2=new Panel();
		p.setLayout(new BorderLayout());
		p1.setLayout(new BorderLayout());
		p2.setLayout(new BorderLayout());
        p.add("North",label1);
		p1.add("North",textfield1);
		p.add(label2);
		p1.add(textfield2);
		p.add("South",label3);
		p1.add("South",textfield3);
		p2.add("West",button1);
		p2.add("East",button2);
		add("West",p);
		add("East",p1);
		add("South",p2);
	    setBackground(Color.gray);
		
	}
	//action 方法处理事件
	public boolean action(Event e,Object o){
		DES des=new DES();
	//处理按纽情况	    
    if(e.target instanceof Button){
        // ****************************按纽1**************************
        	if(e.target==button1){
                  text=new Text(textfield1.getText(),textfield2.getText());
                        
                        
                        des.encrypt(text);
                      textfield3.setText(new String(text.getCipherText()));
	        	      //清空明文
                         
	        	         textfield1.setText(null);
}	        else if(e.target==button2){
          
	                  des.decrypt(text);       
                        textfield1.setText(new String(text.getPlainText()));
                        
                        textfield3.setText(null); 
}                        

	} //按纽情况结束
	return true;
}
}

⌨️ 快捷键说明

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