java EJB 加密与解密原理的一个例子

前端之家收集整理的这篇文章主要介绍了java EJB 加密与解密原理的一个例子前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

加密与解密原理的一个例子 packagelockunlock; importJava.awt.;
importjava.awt.event.
;
importjava.Applet.;
importjavax.Swing.
;
importjava.util.;
publicclassLockUnlockextendsJApplet{
privatebooleanisStandalone=false;
//Getaparametervalue
publicStringgetParameter(Stringkey,Stringdef){
returnisStandalone?System.getProperty(key,def):
(getParameter(key)!=null?getParameter(key):def);
} //Constructtheapplet
publicLockUnlock(){
}
//Initializetheapplet
publicvoidinit(){
try{
jbInit();
}
catch(Exceptione){
e.printStackTrace();
}
}
//Componentinitialization
privatevoidjbInit()throwsException{
contentPane=(JPanel)this.getContentPane();
jLabel1.setText("String");
jLabel1.setBounds(newRectangle(35,36,57,21));
contentPane.setLayout(null);
this.setSize(newDimension(400,300));
jLabel2.setText("Stringlength");
jLabel2.setBounds(newRectangle(29,73,69,22));
jTextField1.setText("");
jTextField1.setBounds(newRectangle(108,40,166,17));
jTextField2.setText("");
jTextField2.setBounds(newRectangle(107,72,56,21));
jButton1.setBounds(newRectangle(30,236,137,27));
jButton1.setText("Exercise3");
jButton1.addActionListener(newLockUnlock_jButton1_actionAdapter(this));
jButton2.setBounds(newRectangle(218,237,131,27));
jButton2.setText("Exercise4");
jButton2.addActionListener(newLockUnlock_jButton2_actionAdapter(this));
jTextField3.setText("");
jTextField3.setBounds(newRectangle(106,105,58,21));
jLabel3.setText("MoShu");
jLabel3.setBounds(newRectangle(36,106,86,18));
contentPane.add(jLabel1,null);
contentPane.add(jButton2,null);
contentPane.add(jButton1,null);
contentPane.add(jLabel3,null);
contentPane.add(jTextField2,null);
contentPane.add(jLabel2,null);
contentPane.add(jTextField3,null);
contentPane.add(jTextField1,null); }
//GetAppletinformation
publicStringgetAppletInfo(){
return"AppletInformation";
}
//Getparameterinfo
publicString[][]getParameterInfo(){
returnnull;
}
//Mainmethod
publicstaticvoidmain(String[]args){
LockUnlockapplet=newLockUnlock();
applet.isStandalone=true;
JFrameframe=newJFrame();
//EXIT_ON_CLOSE==3
frame.setDefaultCloSEOperation(3);
frame.setTitle("AppletFrame");
frame.getContentPane().add(applet,BorderLayout.CENTER);
applet.init();
applet.start();
frame.setSize(400,320);
Dimensiond=Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation((d.width-frame.getSize().width)/2,(d.height-frame.getSize().height)/2);
frame.setVisible(true);
} //staticinitializerforsettinglook&feel
static{
try{
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}
catch(Exceptione){
}
}
//DeclareDataMember
intindex; //-----------------------------------------------------
JPanelcontentPane;
JLabeljLabel1=newJLabel();
JLabeljLabel2=newJLabel();
JTextFieldjTextField2=newJTextField();
JTextFieldjTextField1=newJTextField();
JButtonjButton1=newJButton();
JButtonjButton2=newJButton();
JTextFieldjTextField3=newJTextField();
JLabeljLabel3=newJLabel(); //----------------------N!------------------------------
publicintfunction(intN){
if(N==1)
return1;
else{
returnN
function(N-1);
/不是RETURNfunction(N-1);
而是N
function(N-1);/
}
}
//-----------用递归法求一个串的全排列-----------------------
publicvoidArrange(Stringprefix,Stringsuffix,int[]Array){
StringnewPrefix,newSuffix;
intnumOfChars=suffix.length();
if(numOfChars==1){
Array[index]=Integer.parseInt(prefix+suffix);
index++;
}
else{
for(inti=1;i<=numOfChars;i++){
newSuffix=suffix.substring(1,numOfChars);
newPrefix=prefix+suffix.charAt(0);
Arrange(newPrefix,newSuffix,Array);
suffix=newSuffix+suffix.charAt(0);
}
}
}
//----------ArrangeFromtheMintotheMax------------------
/
publicvoidRankForArrange(int[]Array){
intbottom=Array.length-1;
inttemp;
for(inti=bottom;i>0;i--){
for(intj=0;j<i;j++){
if(Array[j]>Array[j+1]){
temp=Array[j];
Array[j]=Array[j+1];
Array[j+1]=temp;
}
}
}
}
/
//-------------------Findtheaimnumber----------------------
publicintFindAim(intaim,int[]Array){
booleanisFound=false;
intlocation=0;
intlength=Array.length;
for(inti=0;i<length;i++){
if(Array[i]==aim){
location=i;
isFound=true;
}
}
if(isFound)
returnlocation;
else
System.out.println("NotFound");
returnlocation;
/
在if里return不行吗?/
} //------------------CreatString-------------------------------
publicStringCreatString(intlength){
StringBufferBufString=newStringBuffer();
for(inti=1;i<=length;i++){
BufString.append(i);
}
returnBufString.toString();
}
//-----------OutPutResult--------------------
publicvoidOutPutResult1(){
index=0;//clearto0
StringAimString,prefix;
AimString=jTextField1.getText();
intLength=AimString.length();
StringstrLength=String.valueOf(Length);
intAim=Integer.parseInt(AimString);
/
方法.parseInt才是转换为int类型
而不是.getInteger*/
int[]EachArrange=newint[this.function(Length)];
jTextField2.setText(strLength);
prefix="";//MakeanemptyString
if(AimString.length()>2&&
AimString.length()<9&&AimString!=""){
Arrange(prefix,AimString,EachArrange);
//RankForArrange(EachArrange);
Arrays.sort(EachArrange);
Stringresult=String.valueOf(FindAim(Aim,EachArrange));
jTextField3.setText(result);
}
else{
System.out.println("YourStringistooshort");
}
} //----------Outputresult2---------------------
publicvoidOutPutRestlt2(){
index=0;//Letindexcomebackto0
StringstrLength,strMoShu,
AimString,prefix,suffix;
intLength,MoShu,limit;
strLength=jTextField2.getText();
strMoShu=jTextField3.getText();
Length=Integer.parseInt(strLength);
MoShu=Integer.parseInt(strMoShu);
limit=function(Length);
int[]EachArrange=newint[this.function(Length)];
if(Length>2&&Length<9&&
strLength!=""&&strMoShu!=""
&&MoShu<limit){
prefix="";
suffix=CreatString(Length);
Arrange(prefix,suffix,EachArrange);
Arrays.sort(EachArrange);
StringstrResult=String.valueOf(EachArrange[MoShu]);
jTextField1.setText(strResult);
}
else
System.out.println("InputOufMoShu,Tryagain");
} voidjButton1_actionPerformed(ActionEvente){
this.OutPutResult1();
} voidjButton2_actionPerformed(ActionEvente){
this.OutPutRestlt2();
}
//----------------------------------------------------------- } classLockUnlock_jButton1_actionAdapterimplementsjava.awt.event.ActionListener{
LockUnlockadaptee; LockUnlock_jButton1_actionAdapter(LockUnlockadaptee){
this.adaptee=adaptee;
}
publicvoidactionPerformed(ActionEvente){
adaptee.jButton1_actionPerformed(e);
}
} classLockUnlock_jButton2_actionAdapterimplementsjava.awt.event.ActionListener{
LockUnlockadaptee; LockUnlock_jButton2_actionAdapter(LockUnlockadaptee){
this.adaptee=adaptee;
}
publicvoidactionPerformed(ActionEvente){
adaptee.jButton2_actionPerformed(e);
}
}

原文链接:https://www.f2er.com/php/29789.html

猜你在找的PHP相关文章