用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - java代码库

IDEA加密工具

2013-08-26 作者: 流风清音举报

[java]代码库

import com.ms.wfc.app.*;
import com.ms.wfc.core.*;
import com.ms.wfc.ui.*;
import com.ms.wfc.html.*;

/**
 * This class can take a variable number of parameters on the command
 * line. Program execution begins with the main() method. The class
 * constructor is not invoked unless an object of type 'FormIDEAwindow'
 * created in the main() method.
 */
public class FormIDEAwindow extends Form
{
	public static int MtoCorCtoM;						//加密或脱密类型:0为加密
	
	public static final int TYPE_M_TO_C = 0;			//代表加密的常量
	public static final int TYPE_C_TO_M = 1;			//代表脱密的常量
	
	public static final int maxim=65537;				//常量2的16次方加1,即65537
	public static final int fuyi=65536;					//常量2的16次方,即65536
	public static final int one=65535;					//常量65535,即低16位为1的整型
	public static final int round=8;
	
	int group;											//正在进行的分组组数
	Count16[] count16MorC;								//16进制的明文或密文数组
	String strCorM = new String("");					//16进制的明文或密文的字符串保存形式
	char[][] Z = new char[7][10];						//加密密钥:Z[4][6]表示第6圈的第4个加密密钥
	char[][] DK = new char[7][10];						//脱密密钥:DK[2][9]表示第9圈即输出变换圈的第2个脱密密钥
	char[] XX = new char[5];							//128比特的明文或密文表示形式
	char[] userKey = new char[9];						//用户输入的128位初始密钥
	
	public FormIDEAwindow()
	{
		super();

		// Required for Visual J++ Form Designer support
		initForm();		

		// TODO: Add any constructor code after initForm call
	}

	/**
	 * FormIDEAwindow overrides dispose so it can clean up the
	 * component list.
	 */
	public void dispose()
	{
		super.dispose();
		components.dispose();
	}

	private void menuItemIDEABegin_click(Object source, Event e)		//开始按钮
	{
		if(menuItemIDEABegin.getText().equals("重来"))
		{
			super.dispose();
			components.dispose();
			Application.run(new FormIDEAwindow());
		}
		else
		{
			panelIDEA.setVisible(false);
			labelIDEAInstruction.setVisible(true);
			labelIDEAInputMorC.setVisible(true);
			labelIDEAMorClength.setVisible(true);
			richEditIDEAInputMorC.setVisible(true);
			labelIDEAInputK.setVisible(true);
			labelIDEAKlength.setVisible(true);
			richEditIDEAInputK.setVisible(true);
			labelIDEACheckInputMorC.setVisible(true);
			labelIDEACheckInputK.setVisible(true);	
			buttonIDEACalculate.setVisible(true);
			labelIDEAKResult.setVisible(true);
			richEditIDEAKResult.setVisible(true);
			labelIDEAResult.setVisible(true);
			richEditIDEAResult.setVisible(true);
			menuItemIDEABegin.setText("重来");
			if(MtoCorCtoM == TYPE_M_TO_C)
			{
				labelIDEADataFillType.setVisible(true);
				labelIDEAChangeDataFillType.setVisible(true);
				buttonIDEAChangeDataFillType.setVisible(true);
				labelIDEAInstruction.setText("这个程序用来进行IDEA分组密码算法的加密运算");
				labelIDEAInputMorC.setText("请输入初始明文");
				labelIDEAInputK.setText("请输入用户密钥");
				buttonIDEACalculate.setText("加密");
				labelIDEAKResult.setText("生成密钥");
				labelIDEAResult.setText("生成密文:");
			}
			else
			{
				labelIDEAInstruction.setText("这个程序用来进行IDEA分组密码算法的脱密运算");
				labelIDEAInputMorC.setText("请输入初始密文");
				labelIDEAInputK.setText("请输入用户密钥");
				buttonIDEACalculate.setText("脱密");
				labelIDEAKResult.setText("生成密钥");
				labelIDEAResult.setText("生成明文:");
			}
		}
	}

	private void menuItemIDEABack_click(Object source, Event e)			//返回按钮
	{
		super.dispose();
		components.dispose();
		Application.run(new Form1());
	}

	private void menuItemIDEAExit_click(Object source, Event e)			//退出按钮
	{
		int result = MessageBox.show("感谢使用本软件。\n你真的要退出本程序吗?","密码学算法软件",MessageBox.OKCANCEL+MessageBox.ICONQUESTION+MessageBox.DEFBUTTON1);
		if(result==DialogResult.OK)
		{
			super.dispose();
			components.dispose();
			Application.exit();
		}
		else
		{
		}
	}

	private void richEditIDEAInputMorC_textChanged(Object source, Event e)				//显示输入明密文长度
	{
		labelIDEAMorClength.setText("长度:"+richEditIDEAInputMorC.getText().length()+",即"+richEditIDEAInputMorC.getText().length()*4+"bit");
	}

	private void richEditIDEAInputK_textChanged(Object source, Event e)					//显示输入密钥长度
	{
		labelIDEAKlength.setText("长度:"+richEditIDEAInputK.getText().length()+",即"+richEditIDEAInputK.getText().length()*4+"bit");
	}

	private void buttonIDEAChangeDataFillType_click(Object source, Event e)				//加密时需改变数据填充类型
	{
		comboBoxIDEAChangeDataFillType.setVisible(true);
		buttonIDEAChangeDataFillType.setVisible(false);
		buttonIDEACalculate.setEnabled(false);
	}

	private void comboBoxIDEAChangeDataFillType_selectedIndexChanged(Object source, Event e)
	{
		if((String)comboBoxIDEAChangeDataFillType.getSelectedItem() != null)			//选择填充方式
		{
			buttonIDEACalculate.setEnabled(true);
		}	
	}

	private void key(char[] usekey)									//生成加密密钥
	{
		if(usekey.length==9)
		{
			char[] S = new char[52];
			int i,j,r;
			
			for(i=1;i<9;i++)										//S[1],S[2],……S[8]
			{
				S[i-1]=usekey[i];
			}
			for(i=8;i<52;i++)
			{
				if((i+2)%8==0)										//S[14],S[22],……
				{
					S[i]=(char)(((int)((char)((int)S[i-7]<<9))^(int)((char)((int)S[i-14]>>7)))&one);
				}
				else
				{
					if((i+1)%8==0)									//S[15],S[23],……
					{
						S[i]=(char)(((int)((char)((int)S[i-15]<<9))^(int)((char)((int)S[i-14]>>7)))&one);
					}					
					else
					{
						S[i]=(char)(((int)((char)((int)S[i-7]<<9))^(int)((char)((int)S[i-6]>>7)))&one);
					}
				}
			}
			for(r=1;r<=round;r++)									//形成加密密钥Z
			{
				for(j=1;j<=6;j++)
				{	
					Z[j][r]=S[6*(r-1)+j-1];
				}
			}
			if(r==round+1)
			{
				for(j=1;j<=4;j++)
				{
					Z[j][r]=S[6*(r-1)+j-1];
				}
			}
		}
	}
	
	private void de_key(char[][] Zkey)								//生成脱密密钥DK
	{
		if(Zkey.length==7&Zkey[0].length==10)
		{
			int i,j;
			
			for(j=1;j<=round+1;j++)
			{
				DK[1][round-j+2]=(char)Maths.inverse((int)Zkey[1][j],maxim);
				DK[4][round-j+2]=(char)Maths.inverse((int)Zkey[4][j],maxim);
				if(j==1||j==round+1)
				{
					DK[2][round-j+2]=(char)((fuyi-(int)Zkey[2][j])&one);
					DK[3][round-j+2]=(char)((fuyi-(int)Zkey[3][j])&one);
				}
				else
				{
					DK[2][round-j+2]=(char)((fuyi-(int)Zkey[3][j])&one);
					DK[3][round-j+2]=(char)((fuyi-(int)Zkey[2][j])&one);
				}
			}
			for(j=1;j<=round+1;j++)
			{
				DK[5][round+1-j]=Zkey[5][j];
				DK[6][round+1-j]=Zkey[6][j];
			}
		}
	}
	
	private void keyPrint(char[][] Key)								//加脱密密钥打印
	{
		int i,j,k;
		String strK;
		Count16[] count16print = new Count16[4];
		for(i=0; i<4; i++)
		{
			count16print[i] = new Count16();
		}
		
		strK = "     ";
		for(i=1; i<7; i++)
		{
			if(MtoCorCtoM==TYPE_M_TO_C)
			{
				strK = strK+"   Z"+i+" ";
			}
			else
			{
				strK = strK+"   U"+i+" ";
			}
		}
		for(i=1; i<9; i++)
		{
			strK = strK+"第"+i+"圈: ";
			for(j=1; j<7; j++)
			{
				count16print = Count16.shortToCount16(Key[j][i]);
				for(k=0; k<4; k++)
				{
					strK = strK+count16print[k].gethex();
				}
				if(j<6)
				{
					strK = strK+"  ";
				}
			}
		}
		strK = strK+"第"+i+"圈: ";
		for(j=1; j<5; j++)
		{
			count16print = Count16.shortToCount16(Key[j][i]);
			for(k=0; k<4; k++)
			{
				strK = strK+count16print[k].gethex();
			}
			if(j<4)
			{
				strK = strK+"  ";
			}
		}
		
		richEditIDEAKResult.setText(strK);
	}
			
	private void buttonIDEACalculate_click(Object source, Event e)		//加密或脱密计算按钮
	{
		int col,row;
		boolean rightInput = false;
		String strMorC;
		String strK;
		strMorC = richEditIDEAInputMorC.getText();
		strK = richEditIDEAInputK.getText();
		if(strMorC.equals("")|strK.equals(""))							//明密文或密钥为空
		{
		}
		else
		{
			char[] chMorC = new char[strMorC.length()];
			char[] chK = new char[strK.length()];
			chMorC = strMorC.toCharArray();
			chK = strK.toCharArray();
			
			for(col=0; col<chMorC.length; col++)
			{
				if(chMorC[col]< '0'|(chMorC[col]> '9'&chMorC[col]< 'A')|chMorC[col]> 'F')	//检测输入合法性
				{
					if(MtoCorCtoM == TYPE_M_TO_C)
					{
						if(chMorC[col]==' ')
						{
							labelIDEACheckInputMorC.setText("明文中第"+(col+1)+"位字符是空格,请删除");
						}
						else
						{
							labelIDEACheckInputMorC.setText("明文中第"+(col+1)+"位字符不合法");
						}
					}
					else
					{
						if(chMorC[col]==' ')
						{
							labelIDEACheckInputMorC.setText("密文中第"+(col+1)+"位字符是空格,请删除");
						}
						else
						{
							labelIDEACheckInputMorC.setText("密文中第"+(col+1)+"位字符不合法");
						}
					}
					rightInput = false;
					break;
				}
			}
			if(col==chMorC.length)
			{
				labelIDEACheckInputMorC.setText("");
			}
			for(row=0; row<chK.length; row++)
			{
				if(chK[row]< '0'|(chK[row]> '9'&chK[row]< 'A')|chK[row]> 'F')
				{
					if(chK[row]==' ')
					{
						labelIDEACheckInputK.setText("密钥中第"+(row+1)+"位字符是空格,请删除");
					}
					else
					{
						labelIDEACheckInputK.setText("密钥中第"+(row+1)+"位字符不合法");
					}
					rightInput = false;
					break;
				}
			}
			if(row==chK.length)
			{
				labelIDEACheckInputK.setText("");
			}
			if(col==chMorC.length & row==chK.length)
			{
				rightInput = true;
			}
			if(chK.length!=32)														//长度检测
			{
				labelIDEACheckInputK.setText("密钥长度必须为128bit,即32个字符");
				rightInput = false;
			}
			if(MtoCorCtoM==TYPE_C_TO_M && chMorC.length%16!=0)
			{
				labelIDEACheckInputMorC.setText("密文长度必须为64bit的整数倍");
				rightInput = false;
			}
			if(rightInput==true)													//检测输入正确时
			{
				labelIDEACheckInputMorC.setText("");
				labelIDEACheckInputK.setText("");
				
				Count16[] count16temp = new Count16[4];
				for(col=0; col<4; col++)
				{
					count16temp[col] = new Count16();
				}
				
				for(col=0; col<32; col=col+4)
				{
					for(row=0; row<4; row++)
					{
						count16temp[row].sethex(chK[col+row]);
					}					
					userKey[col/4+1] = Count16.toshort(count16temp);				//生成用户密钥
				}
				key(userKey);														//生成密钥
				if(MtoCorCtoM==TYPE_C_TO_M)											//生成脱密密钥并打印
				{
					de_key(Z);
					keyPrint(DK);
				}
				else																//打印加密密钥
				{
					keyPrint(Z);
				}
				
				count16MorC = new Count16[((chMorC.length-1)/16+1)*16];				//明密文存储内存分配
				for(col=0; col<count16MorC.length; col++)
				{
					count16MorC[col] = new Count16();
				}
				for(col=0; col<chMorC.length; col++)
				{
					count16MorC[col].sethex(chMorC[col]);
				}
									
				if(MtoCorCtoM==TYPE_M_TO_C && buttonIDEAChangeDataFillType.getVisible()==false)
				{
					for(col=chMorC.length; col<count16MorC.length; col++)			//默认填充0
					{
						count16MorC[col].sethex('0');
					}
					
					String strDataFillType;
					strDataFillType = (String)comboBoxIDEAChangeDataFillType.getSelectedItem();
					if(strDataFillType.equals("填充 0 (默认)"))
					{
					}
					if(strDataFillType.equals("填充 1"))							//填充1
					{
						for(col=chMorC.length; col<count16MorC.length; col++)
						{
							count16MorC[col].sethex('F');
						}
					}
					if(strDataFillType.equals("填充0和1(先0后1)"))					//填充01
					{
						for(col=chMorC.length; col<count16MorC.length; col++)
						{
							count16MorC[col].sethex('5');
						}
					}
					if(strDataFillType.equals("填充1和0(先1后0)"))					//填充10
					{
						for(col=chMorC.length; col<count16MorC.length; col++)
						{
							count16MorC[col].sethex('A');
						}
					}					
				}
				
				for(group=1; group<=(count16MorC.length/16); group++)				//分组信息
				{
					for(col=(group-1)*16,row=0; row<16; col++,row++)
					{
						count16temp[row%4].sethex(count16MorC[col].gethex());
						if(row%4==3)
						{
							XX[row/4+1] = Count16.toshort(count16temp);
						}
					}
					
					if(MtoCorCtoM == TYPE_M_TO_C)									//加密计算
					{
						cip(XX,Z);
					}
					else															//脱密计算
					{
						cip(XX,DK);
					}					
				}
				
				richEditIDEAResult.setText(strCorM);
				strCorM = "";
				
				buttonIDEACalculate.setEnabled(false);
				richEditIDEAInputK.setEnabled(false);
				richEditIDEAInputMorC.setEnabled(false);
				richEditIDEAInputK.setBackColor(Color.LIGHTGRAY);
				richEditIDEAInputMorC.setBackColor(Color.LIGHTGRAY);
				buttonIDEAChangeDataFillType.setEnabled(false);
				comboBoxIDEAChangeDataFillType.setEnabled(false);
				comboBoxIDEAChangeDataFillType.setBackColor(Color.LIGHTGRAY);
			}
		}
	}
	
	private void cip(char[] IN,char[][] KEY)										//加密函数	
	{
		int i,j,r;
		char[] OUT = new char[5];
		char[] x = new char[5];
		char kk,t1,t2,a;
		Count16[] roundOut = new Count16[4];
		for(i=0; i<4; i++)
		{
			roundOut[i] = new Count16();
		}
		
		strCorM = strCorM + "*****************************************";
		if(MtoCorCtoM == TYPE_M_TO_C)
		{
			strCorM = strCorM + "第"+group+"组密文:                               ";
		}
		else
		{
			strCorM = strCorM + "第"+group+"组明文:                               ";
		}
		strCorM = strCorM + "-----------------------------------------";
		x[1]=IN[1];
		x[2]=IN[2];
		x[3]=IN[3];
		x[4]=IN[4];
		
		for(r=1;r<=8;r++)															//8圈迭代.
		{
			x[1]=mul(x[1],KEY[1][r]);
			x[2]=(char)(((int)x[2]+(int)KEY[2][r])&one);
			x[3]=(char)(((int)x[3]+(int)KEY[3][r])&one);
			x[4]=mul(x[4],KEY[4][r]);
																					//乘加(MA)结构.
			kk=mul(KEY[5][r],(char)((int)x[1]^(int)x[3]));
			t1=mul(KEY[6][r],(char)(((int)kk+((int)x[2]^(int)x[4]))&one));
			t2=(char)(((int)kk+(int)t1)&one);
																					//下一圈输入交换.
			x[1]=(char)((int)x[1]^(int)t1);
			x[4]=(char)((int)x[4]^(int)t2);
			a=(char)((int)x[2]^(int)t2);
			x[2]=(char)((int)x[3]^(int)t1);
			x[3]=a;
			
			strCorM = strCorM+"第"+r+"圈输出:       ";
			for(i=1; i<5; i++)
			{
				roundOut = Count16.shortToCount16( x[i] );
				for(j=0; j<4; j++)
				{
					strCorM = strCorM + roundOut[j].gethex();
				}
				strCorM = strCorM + "  ";
			}
		}
																					//输出变换得出加脱密结果.
		OUT[1]=mul(x[1],KEY[1][round+1]);
		OUT[4]=mul(x[4],KEY[4][round+1]);
		OUT[2]=(char)((x[3]+KEY[2][round+1])&one);
		OUT[3]=(char)((x[2]+KEY[3][round+1])&one);
		
		if(MtoCorCtoM == TYPE_M_TO_C)												//为打印作准备
		{
			if(group<=9)
			{
				strCorM = strCorM+"第"+group+"组加密结果:   ";
			}
			else
			{
				strCorM = strCorM+"第"+group+"组加密结果:  ";
			}
		}
		else
		{
			if(group<=9)
			{
				strCorM = strCorM+"第"+group+"组脱密结果:   ";
			}
			else
			{
				strCorM = strCorM+"第"+group+"组脱密结果:  ";
			}
		}
		for(i=1; i<5; i++)
		{
			roundOut = Count16.shortToCount16( OUT[i] );
			for(j=0; j<4; j++)
			{
				strCorM = strCorM + roundOut[j].gethex();
			}
			strCorM = strCorM + "  ";
		}
		strCorM = strCorM+"*****************************************";
	}
	
	private char mul(char a,char b)													//模2的16次方加1运算
	{
		int p;
		long q;
		if((int)a==0)
		{
			p=maxim-(int)b;
		}
		else
		{
			if((int)b==0)
			{
				p=maxim-(int)a;
			}
			else
			{
				q=(long)a*(long)b;
				if((q&((long)one))>(long)(q>>16))
				{
					p=(int)((q&((long)one))-(long)(q>>16));
				}
				else
				{
					p=(int)((q&((long)one))+(long)maxim-(long)(q>>16));
				}
			}
		}
		return (char)(p&one);
	}	
	
	private void menuItemHelp_click(Object source, Event e)
	{
		MessageBox.show("IDEA算法使用帮助:\n  输入框内可以输入字符\n0-9以及大字字母A-F,注意小写字母不行。\n如果输入的字符不能通过检查,请确认是否输入了回车键。\n如有,请将回车字符删去。\n\n说明:\n  剪切: Ctrl+X\n  复制: Ctrl+C\n  粘贴: Ctrl+V"
						,"请注意",MessageBox.OK+MessageBox.ICONEXCLAMATION+MessageBox.DEFBUTTON1);
	}

	/**
	 * NOTE: The following code is required by the Visual J++ form
	 * designer.  It can be modified using the form editor.  Do not
	 * modify it using the code editor.
	 */
	Container components = new Container();
	MainMenu mainMenuIDEA = new MainMenu();
	MenuItem menuItemIDEABegin = new MenuItem();
	MenuItem menuItemIDEABack = new MenuItem();
	MenuItem menuItemIDEAExit = new MenuItem();
	Label labelIDEAInstruction = new Label();
	RichEdit richEditIDEAResult = new RichEdit();
	Button buttonIDEACalculate = new Button();
	Label labelIDEACheckInputMorC = new Label();
	ComboBox comboBoxIDEAChangeDataFillType = new ComboBox();
	Button buttonIDEAChangeDataFillType = new Button();
	Label labelIDEAChangeDataFillType = new Label();
	Label labelIDEAInputMorC = new Label();
	Label labelIDEADataFillType = new Label();
	RichEdit richEditIDEAInputK = new RichEdit();
	Label labelIDEAKlength = new Label();
	Label labelIDEAMorClength = new Label();
	RichEdit richEditIDEAInputMorC = new RichEdit();
	Label labelIDEAInputK = new Label();
	Label labelIDEACheckInputK = new Label();
	RichEdit richEditIDEAKResult = new RichEdit();
	Label labelIDEAKResult = new Label();
	Label labelIDEAResult = new Label();
	MenuItem menuItemHelp = new MenuItem();
	Panel panelIDEA = new Panel();
	PictureBox pictureBoxIDEA = new PictureBox();
	RichEdit richEditBegin = new RichEdit();
	RichEdit richEditzhuyi = new RichEdit();

	private void initForm()
	{
		// NOTE:  This form is storing resource information in an
		// external file.  Do not modify the string parameter to any
		// resources.getObject() function call. For example, do not
		// modify "foo1_location" in the following line of code
		// even if the name of the Foo object changes: 
		//   foo1.setLocation((Point)resources.getObject("foo1_location"));

		IResourceManager resources = new ResourceManager(this, "FormIDEAwindow");
		menuItemIDEABegin.setText("开始");
		menuItemIDEABegin.addOnClick(new EventHandler(this.menuItemIDEABegin_click));

		menuItemIDEABack.setText("返回");
		menuItemIDEABack.addOnClick(new EventHandler(this.menuItemIDEABack_click));

		menuItemIDEAExit.setText("退出");
		menuItemIDEAExit.addOnClick(new EventHandler(this.menuItemIDEAExit_click));

		labelIDEAInstruction.setFont(new Font("宋体", 16.0f, FontSize.POINTS, FontWeight.BOLD, false, false, false, CharacterSet.DEFAULT, 0));
		labelIDEAInstruction.setForeColor(Color.BLACK);
		labelIDEAInstruction.setLocation(new Point(32, 16));
		labelIDEAInstruction.setSize(new Point(288, 48));
		labelIDEAInstruction.setTabIndex(0);
		labelIDEAInstruction.setTabStop(false);
		labelIDEAInstruction.setText("");
		labelIDEAInstruction.setVisible(false);

		richEditIDEAResult.setBackColor(new Color(204, 255, 51));
		richEditIDEAResult.setFont(new Font("宋体", 14.0f, FontSize.POINTS, FontWeight.NORMAL, false, false, false, CharacterSet.DEFAULT, 0));
		richEditIDEAResult.setForeColor(Color.WINDOWTEXT);
		richEditIDEAResult.setLocation(new Point(376, 184));
		richEditIDEAResult.setSize(new Point(400, 328));
		richEditIDEAResult.setTabIndex(13);
		richEditIDEAResult.setText("");
		richEditIDEAResult.setVisible(false);
		richEditIDEAResult.setReadOnly(true);
		richEditIDEAResult.setScrollBars(RichEditScrollBars.FORCED_VERTICAL);

		buttonIDEACalculate.setFont(new Font("宋体", 18.0f, FontSize.POINTS, FontWeight.BOLD, false, false, false, CharacterSet.DEFAULT, 0));
		buttonIDEACalculate.setLocation(new Point(272, 392));
		buttonIDEACalculate.setSize(new Point(64, 48));
		buttonIDEACalculate.setTabIndex(12);
		buttonIDEACalculate.setText("");
		buttonIDEACalculate.setVisible(false);
		buttonIDEACalculate.addOnClick(new EventHandler(this.buttonIDEACalculate_click));

		labelIDEACheckInputMorC.setBackColor(new Color(153, 77, 0));
		labelIDEACheckInputMorC.setFont(new Font("宋体", 14.0f, FontSize.POINTS, FontWeight.BOLD, false, false, false, CharacterSet.DEFAULT, 0));
		labelIDEACheckInputMorC.setForeColor(Color.BLACK);
		labelIDEACheckInputMorC.setLocation(new Point(16, 336));
		labelIDEACheckInputMorC.setSize(new Point(320, 20));
		labelIDEACheckInputMorC.setTabIndex(11);
		labelIDEACheckInputMorC.setTabStop(false);
		labelIDEACheckInputMorC.setText("");
		labelIDEACheckInputMorC.setVisible(false);
		labelIDEACheckInputMorC.setTextAlign(HorizontalAlignment.CENTER);

		comboBoxIDEAChangeDataFillType.setBackColor(new Color(204, 255, 51));
		comboBoxIDEAChangeDataFillType.setFont(new Font("宋体", 9.0f, FontSize.POINTS, FontWeight.NORMAL, false, false, false, CharacterSet.DEFAULT, 0));
		comboBoxIDEAChangeDataFillType.setLocation(new Point(16, 472));
		comboBoxIDEAChangeDataFillType.setSize(new Point(192, 20));
		comboBoxIDEAChangeDataFillType.setTabIndex(10);
		comboBoxIDEAChangeDataFillType.setText("");
		comboBoxIDEAChangeDataFillType.setVisible(false);
		comboBoxIDEAChangeDataFillType.setStyle(ComboBoxStyle.DROPDOWNLIST);
		comboBoxIDEAChangeDataFillType.setItems(new Object[] {
												"填充 0 (默认)", 
												"填充 1", 
												"填充0和1(先0后1)", 
												"填充1和0(先1后0)"});
		comboBoxIDEAChangeDataFillType.addOnSelectedIndexChanged(new EventHandler(this.comboBoxIDEAChangeDataFillType_selectedIndexChanged));

		buttonIDEAChangeDataFillType.setFont(new Font("宋体", 9.0f, FontSize.POINTS, FontWeight.NORMAL, false, false, false, CharacterSet.DEFAULT, 0));
		buttonIDEAChangeDataFillType.setLocation(new Point(216, 448));
		buttonIDEAChangeDataFillType.setSize(new Point(32, 24));
		buttonIDEAChangeDataFillType.setTabIndex(9);
		buttonIDEAChangeDataFillType.setText("更改");
		buttonIDEAChangeDataFillType.setVisible(false);
		buttonIDEAChangeDataFillType.addOnClick(new EventHandler(this.buttonIDEAChangeDataFillType_click));

		labelIDEAChangeDataFillType.setFont(new Font("宋体", 12.0f, FontSize.POINTS, FontWeight.NORMAL, true, false, false, CharacterSet.DEFAULT, 0));
		labelIDEAChangeDataFillType.setForeColor(new Color(224, 224, 224));
		labelIDEAChangeDataFillType.setLocation(new Point(16, 448));
		labelIDEAChangeDataFillType.setSize(new Point(192, 16));
		labelIDEAChangeDataFillType.setTabIndex(8);
		labelIDEAChangeDataFillType.setTabStop(false);
		labelIDEAChangeDataFillType.setText("改变默认的数据填充类型");
		labelIDEAChangeDataFillType.setVisible(false);
		labelIDEAChangeDataFillType.setTextAlign(HorizontalAlignment.CENTER);

		labelIDEAInputMorC.setFont(new Font("宋体", 12.0f, FontSize.POINTS, FontWeight.BOLD, false, false, false, CharacterSet.DEFAULT, 0));
		labelIDEAInputMorC.setForeColor(Color.BLACK);
		labelIDEAInputMorC.setLocation(new Point(8, 88));
		labelIDEAInputMorC.setSize(new Point(152, 23));
		labelIDEAInputMorC.setTabIndex(1);
		labelIDEAInputMorC.setTabStop(false);
		labelIDEAInputMorC.setText("");
		labelIDEAInputMorC.setVisible(false);

		labelIDEADataFillType.setFont(new Font("宋体", 12.0f, FontSize.POINTS, FontWeight.NORMAL, true, false, false, CharacterSet.DEFAULT, 0));
		labelIDEADataFillType.setForeColor(new Color(224, 224, 224));
		labelIDEADataFillType.setLocation(new Point(16, 424));
		labelIDEADataFillType.setSize(new Point(248, 16));
		labelIDEADataFillType.setTabIndex(7);
		labelIDEADataFillType.setTabStop(false);
		labelIDEADataFillType.setText("数据填充类型:填充 0 (默认)");
		labelIDEADataFillType.setVisible(false);
		labelIDEADataFillType.setTextAlign(HorizontalAlignment.CENTER);

		richEditIDEAInputK.setBackColor(new Color(204, 255, 51));
		richEditIDEAInputK.setFont(new Font("宋体", 14.0f, FontSize.POINTS, FontWeight.NORMAL, false, false, false, CharacterSet.DEFAULT, 0));
		richEditIDEAInputK.setForeColor(Color.WINDOWTEXT);
		richEditIDEAInputK.setLocation(new Point(8, 248));
		richEditIDEAInputK.setSize(new Point(328, 80));
		richEditIDEAInputK.setTabIndex(6);
		richEditIDEAInputK.setText("");
		richEditIDEAInputK.setVisible(false);
		richEditIDEAInputK.setScrollBars(RichEditScrollBars.VERTICAL);
		richEditIDEAInputK.addOnTextChanged(new EventHandler(this.richEditIDEAInputK_textChanged));

		labelIDEAKlength.setFont(new Font("宋体", 12.0f, FontSize.POINTS, FontWeight.BOLD, false, false, false, CharacterSet.DEFAULT, 0));
		labelIDEAKlength.setForeColor(Color.BLACK);
		labelIDEAKlength.setLocation(new Point(168, 216));
		labelIDEAKlength.setSize(new Point(192, 23));
		labelIDEAKlength.setTabIndex(5);
		labelIDEAKlength.setTabStop(false);
		labelIDEAKlength.setText("");

		labelIDEAMorClength.setFont(new Font("宋体", 12.0f, FontSize.POINTS, FontWeight.BOLD, false, false, false, CharacterSet.DEFAULT, 0));
		labelIDEAMorClength.setForeColor(Color.BLACK);
		labelIDEAMorClength.setLocation(new Point(168, 88));
		labelIDEAMorClength.setSize(new Point(192, 23));
		labelIDEAMorClength.setTabIndex(4);
		labelIDEAMorClength.setTabStop(false);
		labelIDEAMorClength.setText("");

		richEditIDEAInputMorC.setBackColor(new Color(204, 255, 51));
		richEditIDEAInputMorC.setFont(new Font("宋体", 14.0f, FontSize.POINTS, FontWeight.NORMAL, false, false, false, CharacterSet.DEFAULT, 0));
		richEditIDEAInputMorC.setForeColor(Color.WINDOWTEXT);
		richEditIDEAInputMorC.setLocation(new Point(8, 120));
		richEditIDEAInputMorC.setSize(new Point(328, 80));
		richEditIDEAInputMorC.setTabIndex(3);
		richEditIDEAInputMorC.setText("");
		richEditIDEAInputMorC.setVisible(false);
		richEditIDEAInputMorC.setScrollBars(RichEditScrollBars.VERTICAL);
		richEditIDEAInputMorC.addOnTextChanged(new EventHandler(this.richEditIDEAInputMorC_textChanged));

		labelIDEAInputK.setFont(new Font("宋体", 12.0f, FontSize.POINTS, FontWeight.BOLD, false, false, false, CharacterSet.DEFAULT, 0));
		labelIDEAInputK.setForeColor(Color.BLACK);
		labelIDEAInputK.setLocation(new Point(8, 216));
		labelIDEAInputK.setSize(new Point(152, 23));
		labelIDEAInputK.setTabIndex(2);
		labelIDEAInputK.setTabStop(false);
		labelIDEAInputK.setText("");
		labelIDEAInputK.setVisible(false);

		labelIDEACheckInputK.setFont(new Font("宋体", 14.0f, FontSize.POINTS, FontWeight.BOLD, false, false, false, CharacterSet.DEFAULT, 0));
		labelIDEACheckInputK.setLocation(new Point(16, 360));
		labelIDEACheckInputK.setSize(new Point(320, 20));
		labelIDEACheckInputK.setTabIndex(14);
		labelIDEACheckInputK.setTabStop(false);
		labelIDEACheckInputK.setText("");
		labelIDEACheckInputK.setVisible(false);
		labelIDEACheckInputK.setTextAlign(HorizontalAlignment.CENTER);

		richEditIDEAKResult.setBackColor(new Color(204, 255, 51));
		richEditIDEAKResult.setFont(new Font("宋体", 14.0f, FontSize.POINTS, FontWeight.NORMAL, false, false, false, CharacterSet.DEFAULT, 0));
		richEditIDEAKResult.setForeColor(Color.WINDOWTEXT);
		richEditIDEAKResult.setLocation(new Point(376, 56));
		richEditIDEAKResult.setSize(new Point(400, 88));
		richEditIDEAKResult.setTabIndex(15);
		richEditIDEAKResult.setText("");
		richEditIDEAKResult.setVisible(false);
		richEditIDEAKResult.setReadOnly(true);
		richEditIDEAKResult.setScrollBars(RichEditScrollBars.FORCED_VERTICAL);

		labelIDEAKResult.setFont(new Font("宋体", 15.0f, FontSize.POINTS, FontWeight.BOLD, false, false, false, CharacterSet.DEFAULT, 0));
		labelIDEAKResult.setLocation(new Point(384, 32));
		labelIDEAKResult.setSize(new Point(240, 23));
		labelIDEAKResult.setTabIndex(16);
		labelIDEAKResult.setTabStop(false);
		labelIDEAKResult.setText("");
		labelIDEAKResult.setVisible(false);

		labelIDEAResult.setFont(new Font("宋体", 15.0f, FontSize.POINTS, FontWeight.BOLD, false, false, false, CharacterSet.DEFAULT, 0));
		labelIDEAResult.setLocation(new Point(384, 160));
		labelIDEAResult.setSize(new Point(240, 23));
		labelIDEAResult.setTabIndex(17);
		labelIDEAResult.setTabStop(false);
		labelIDEAResult.setText("");
		labelIDEAResult.setVisible(false);

		menuItemHelp.setText("帮助");
		menuItemHelp.addOnClick(new EventHandler(this.menuItemHelp_click));

		mainMenuIDEA.setMenuItems(new MenuItem[] {
								  menuItemIDEABegin, 
								  menuItemIDEABack, 
								  menuItemIDEAExit, 
								  menuItemHelp});
		/* @designTimeOnly mainMenuIDEA.setLocation(new Point(112, -32)); */

		this.setBackColor(new Color(153, 77, 0));
		this.setForeColor(Color.BLACK);
		this.setText("密码学-IDEA算法");
		this.setAutoScaleBaseSize(new Point(6, 12));
		this.setBorderStyle(FormBorderStyle.FIXED_3D);
		this.setClientSize(new Point(790, 531));
		this.setMaximizeBox(false);
		this.setMenu(mainMenuIDEA);
		this.setStartPosition(FormStartPosition.CENTER_SCREEN);

		panelIDEA.setSize(new Point(792, 536));
		panelIDEA.setTabIndex(19);
		panelIDEA.setText("panel1");

		pictureBoxIDEA.setLocation(new Point(112, 0));
		pictureBoxIDEA.setSize(new Point(680, 536));
		pictureBoxIDEA.setTabIndex(0);
		pictureBoxIDEA.setTabStop(false);
		pictureBoxIDEA.setText("pictureBox1");
		pictureBoxIDEA.setImage((Bitmap)resources.getObject("pictureBoxIDEA_image"));

		richEditBegin.setBackColor(new Color(153, 77, 0));
		richEditBegin.setEnabled(false);
		richEditBegin.setFont(new Font("宋体", 16.0f));
		richEditBegin.setForeColor(new Color(204, 255, 51));
		richEditBegin.setLocation(new Point(8, 0));
		richEditBegin.setSize(new Point(32, 200));
		richEditBegin.setTabIndex(1);
		richEditBegin.setText("请点击开始按钮");
		richEditBegin.setBorderStyle(BorderStyle.NONE);

		richEditzhuyi.setBackColor(new Color(153, 77, 0));
		richEditzhuyi.setEnabled(false);
		richEditzhuyi.setFont(new Font("宋体", 9.0f, FontSize.POINTS, FontWeight.NORMAL, false, false, false, CharacterSet.DEFAULT, 0));
		richEditzhuyi.setForeColor(new Color(204, 255, 51));
		richEditzhuyi.setLocation(new Point(8, 208));
		richEditzhuyi.setSize(new Point(96, 304));
		richEditzhuyi.setTabIndex(2);
		richEditzhuyi.setText("注意:      输入框内只能输入数字0到9和字母A到F,字母为大写。输入其余不符合上述条件的字符本软件均报错误。输入完毕后请点击右边的加脱密按钮即可开始运算。务必不要使用按下回车键来代替按下按钮,如使用了回车键,请将因为按下回车键产生的最后两位字符删去。");
		richEditzhuyi.setBorderStyle(BorderStyle.NONE);

		this.setNewControls(new Control[] {
							panelIDEA, 
							labelIDEAResult, 
							labelIDEAKResult, 
							richEditIDEAKResult, 
							labelIDEACheckInputK, 
							richEditIDEAResult, 
							buttonIDEACalculate, 
							labelIDEACheckInputMorC, 
							comboBoxIDEAChangeDataFillType, 
							buttonIDEAChangeDataFillType, 
							labelIDEAChangeDataFillType, 
							labelIDEADataFillType, 
							richEditIDEAInputK, 
							labelIDEAKlength, 
							labelIDEAMorClength, 
							richEditIDEAInputMorC, 
							labelIDEAInputK, 
							labelIDEAInputMorC, 
							labelIDEAInstruction});
		panelIDEA.setNewControls(new Control[] {
								 richEditzhuyi, 
								 richEditBegin, 
								 pictureBoxIDEA});
	}

	/**
	 * The main entry point for the application. 
	 *
	 * @param args Array of parameters passed to the application
	 * via the command line.
	 */
	public static void main(String args[])
	{
		Application.run(new FormIDEAwindow());
	}
}


网友评论    (发表评论)


发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...