找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 580|回复: 0
打印 上一主题 下一主题

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

[复制链接]

2588

主题

2588

帖子

7694

积分

论坛元老

Rank: 8Rank: 8

积分
7694
跳转到指定楼层
楼主
发表于 2018-2-14 09:24:23 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

            加密与解密原理的一个例子
package lockunlock;  
import Java.awt.*;  
import java.awt.event.*;  
import java.Applet.*;  
import javax.Swing.*;  
import java.util.*;  
public class LockUnlock extends JApplet {  
private boolean isStandalone = false;  
//Get a parameter value  
public String getParameter(String key, String def) {  
return isStandalone ? System.getProperty(key, def) :  
(getParameter(key) != null ? getParameter(key) : def);  
}  
//Construct the applet  
public LockUnlock() {  
}  
//Initialize the applet  
public void init() {  
try {  
jbInit();  
}  
catch(Exception e) {  
e.printStackTrace();  
}  
}  
//Component initialization  
private void jbInit() throws Exception {  
contentPane = (JPanel) this.getContentPane();  
jLabel1.setText("String");  
jLabel1.setBounds(new Rectangle(35, 36, 57, 21));  
contentPane.setLayout(null);  
this.setSize(new Dimension(400, 300));  
jLabel2.setText("String length");  
jLabel2.setBounds(new Rectangle(29, 73, 69, 22));  
jTextField1.setText("");  
jTextField1.setBounds(new Rectangle(108, 40, 166, 17));  
jTextField2.setText("");  
jTextField2.setBounds(new Rectangle(107, 72, 56, 21));  
jButton1.setBounds(new Rectangle(30, 236, 137, 27));  
jButton1.setText("Exercise 3");  
jButton1.addActionListener(new LockUnlock_jButton1_actionAdapter(this));  
jButton2.setBounds(new Rectangle(218, 237, 131, 27));  
jButton2.setText("Exercise 4");  
jButton2.addActionListener(new LockUnlock_jButton2_actionAdapter(this));  
jTextField3.setText("");  
jTextField3.setBounds(new Rectangle(106, 105, 58, 21));  
jLabel3.setText("MoShu");  
jLabel3.setBounds(new Rectangle(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);  
}  
//Get Applet information  
public String getAppletInfo() {  
return "Applet Information";  
}  
//Get parameter info  
public String[][] getParameterInfo() {  
return null;  
}  
//Main method  
public static void main(String[] args) {  
LockUnlock applet = new LockUnlock();  
applet.isStandalone = true;  
JFrame frame = new JFrame();  
//EXIT_ON_CLOSE == 3  
frame.setDefaultCloseOperation(3);  
frame.setTitle("Applet Frame");  
frame.getContentPane().add(applet, BorderLayout.CENTER);  
applet.init();  
applet.start();  
frame.setSize(400,320);  
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();  
frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);  
frame.setVisible(true);  
}  
//static initializer for setting look & feel  
static {  
try {  
//UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());  
//UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());  
}  
catch(Exception e) {  
}  
}  
//Declare DataMember  
int index;  
//-----------------------------------------------------  
JPanel contentPane;  
JLabel jLabel1 = new JLabel();  
JLabel jLabel2 = new JLabel();  
JTextField jTextField2 = new JTextField();  
JTextField jTextField1 = new JTextField();  
JButton jButton1 = new JButton();  
JButton jButton2 = new JButton();  
JTextField jTextField3 = new JTextField();  
JLabel jLabel3 = new JLabel();  
//----------------------N!------------------------------  
public int function(int N){  
if(N==1)  
return 1;  
else{  
return N*function(N-1);  
/*不是RETURN function(N-1);  
而是 N*function(N-1);*/  
}  
}  
//-----------用递归法求一个串的全排列-----------------------  
public void Arrange(String prefix,String suffix,int[] Array){  
String newPrefix,newSuffix;  
int numOfChars =suffix.length();  
if(numOfChars==1){  
Array[index]=Integer.parseInt(prefix+suffix);  
index++;  
}  
else{  
for(int i=1; i0;i--){  
for(int j=0;jArray[j+1]){  
temp =Array[j];  
Array[j] =Array[j+1];  
Array[j+1]=temp;  
}  
}  
}  
}  
*/  
//-------------------Find the aim number----------------------  
public int FindAim(int aim,int[] Array){  
boolean isFound=false;  
int location=0;  
int length=Array.length ;  
for(int i=0;i 2 &&  
AimString.length()  2&&Length
您可能感兴趣的文章:
  • JavaBean(EJB) 3.0 全新体验
  • Java中BEAN与EJB的区别浅析
  • 部署Java在服务器端的EJB组件的方法
            
  • 分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    用户反馈
    客户端