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

📄 setsec_form.java

📁 一个运用J2ME的编程技术在手机里实现了加密与解密的经典算法
💻 JAVA
字号:
package setsec;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;

public class SetSec_Form extends Form implements CommandListener {

	private SetSec_MIDlet ssm;
	private TextField text;
	private TextField setSec;
	private TextField getSec;
	private Command sets_Command;
	private Command gets_Command;
	private Command exit_Command;
	private String str;
	private String encryptStr;
	private String decipherStr;
	public SetSec_Form(SetSec_MIDlet ssm) {
		super("SetSec_System");
		this.ssm=ssm;
	    init();//parseInit this 
	
	}
	public void init()
	{
		//creat the Item
		text=new TextField("Input Your Words",null,100,TextField.ANY);
		setSec=new TextField("Encrypt For Your Words",null,100,TextField.UNEDITABLE);
		getSec=new TextField("Decipher The Encrypted Words",null,100,TextField.UNEDITABLE);
		sets_Command=new Command("Encrypt",Command.OK,1);
		gets_Command=new Command("Decipher",Command.OK,1);
		exit_Command=new Command("Exit",Command.EXIT,1);
		
		//add TextField to Form
		this.append(text);
		this.append(setSec);
		this.append(getSec);
		
		//add Command to Form
		this.addCommand(sets_Command);
		this.addCommand(gets_Command);
		this.addCommand(exit_Command);
		this.setCommandListener(this);
	}

	//creat setSec()
	public void encrypt(String str)
	{
		int length=str.length();
		int []buf=new int[length];
	    for(int i=0;i<length;i++)
	    {
	    	buf[i]=str.charAt(i)+1;
	    }
	    char[] temp=new char[length];
	    for(int i=0;i<buf.length;i++)
	    {
	    	temp[i]=(char)buf[i];
	    }
		encryptStr=new String(temp,0,temp.length);
		
		
		
		
	}
	//creat getSec()
	public String decipher(String secStr)
	{
		int length=secStr.length();
		int []buf=new int [length];
		for(int i=0;i<length;i++)
		{
			buf[i]=secStr.charAt(i)-1;
		}
		char[] temp=new char[length];
		for(int i=0;i<buf.length;i++)
		{
		    	temp[i]=(char)buf[i];
		}
		decipherStr=new String(temp,0,temp.length);
		return str="a";
	}
   //creat CommandAction()
	public void commandAction(Command c, Displayable d) {
		// TODO 自动生成方法存根
		if(c==exit_Command)
		{
			ssm.quitApp();
		}
		else if(c==sets_Command)
		{
			
			str=this.text.getString();
			
			encrypt(str);
			this.setSec.setString(encryptStr);
			
		}
		else if(c==gets_Command)
		{
			decipher(encryptStr);
			this.getSec.setString(decipherStr);
		}

	}

}

⌨️ 快捷键说明

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