Home Backend Development PHP Tutorial An example of java EJB encryption and decryption principles_PHP tutorial

An example of java EJB encryption and decryption principles_PHP tutorial

Jul 21, 2016 pm 03:53 PM
ejb java and example encryption principle of Decrypt

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

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; i<=numOfChars;i++){ 
newSuffix=suffix.substring(1,numOfChars); 
newPrefix=prefix+suffix.charAt(0); 
Arrange(newPrefix,newSuffix,Array); 
suffix=newSuffix+suffix.charAt(0); 



//----------Arrange From the Min to the Max------------------ 
/*public void RankForArrange(int[] Array){ 
int bottom=Array.length-1 ; 
int temp; 
for(int i=bottom;i>0;i--){ 
for(int j=0;jif(Array[j]>Array[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;iif(Array[i]==aim){ 
location=i; 
isFound =true; 


if(isFound) 
return location; 
else 
System.out.println("Not Found"); 
return location; 
/*在if里return 不行吗?*/ 


//------------------Creat String------------------------------- 
public String CreatString(int length){ 
StringBuffer BufString=new StringBuffer(); 
for(int i=1;i<=length;i++){ 
BufString.append(i) ; 

return BufString.toString(); 

//-----------OutPut Result-------------------- 
public void OutPutResult1(){ 
index = 0; //clear to 0 
String AimString, prefix; 
AimString = jTextField1.getText(); 
int Length = AimString.length(); 
String strLength = String.valueOf(Length); 
int Aim = Integer.parseInt(AimString); 
/* 方法.parseInt才是转换为int类型 
而不是.getInteger*/ 
int[] EachArrange = new int[this.function(Length)]; 
jTextField2.setText(strLength); 
prefix = ""; //Make an empty String 
if (AimString.length() > 2 && 
AimString.length() < 9 && AimString != "") { 
Arrange(prefix, AimString, EachArrange); 
//RankForArrange(EachArrange); 
Arrays.sort(EachArrange); 
String result = String.valueOf(FindAim(Aim, EachArrange)); 
jTextField3.setText(result); 

else { 
System.out.println("Your String is too short"); 



//----------Out put result 2--------------------- 
public void OutPutRestlt2(){ 
index=0;//Let index come back to 0 
String strLength, strMoShu, 
AimString, prefix,suffix; 
int Length, MoShu,limit; 
strLength = jTextField2.getText(); 
strMoShu = jTextField3.getText(); 
Length = Integer.parseInt(strLength); 
MoShu = Integer.parseInt(strMoShu); 
limit = function(Length); 
int[] EachArrange = new int[this.function(Length)]; 
if (Length > 2&&Length<9&& 
strLength!=""&&strMoShu!="" 
&&MoShuprefix = ""; 
suffix =CreatString(Length); 
Arrange(prefix, suffix, EachArrange); 
Arrays.sort(EachArrange); 
String strResult=String.valueOf(EachArrange[MoShu]); 
jTextField1.setText(strResult); 

else 
System.out.println("Input Ouf MoShu, Try again") ; 


void jButton1_actionPerformed(ActionEvent e) { 
this.OutPutResult1(); 


void jButton2_actionPerformed(ActionEvent e) { 
this.OutPutRestlt2(); 

//----------------------------------------------------------- 



class LockUnlock_jButton1_actionAdapter implements java.awt.event.ActionListener { 
LockUnlock adaptee; 

LockUnlock_jButton1_actionAdapter(LockUnlock adaptee) { 
this.adaptee = adaptee; 

public void actionPerformed(ActionEvent e) { 
adaptee.jButton1_actionPerformed(e); 



class LockUnlock_jButton2_actionAdapter implements java.awt.event.ActionListener { 
LockUnlock adaptee; 

LockUnlock_jButton2_actionAdapter(LockUnlock adaptee) { 
this.adaptee = adaptee; 

public void actionPerformed(ActionEvent e) { 
adaptee.jButton2_actionPerformed(e); 

}

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/318717.htmlTechArticle加密与解密原理的一个例子 packagelockunlock; importJava.awt.*; importjava.awt.event.*; importjava.Applet.*; importjavax.Swing.*; importjava.util.*; publicclassLockUnlocke...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1662
14
PHP Tutorial
1261
29
C# Tutorial
1234
24
Break or return from Java 8 stream forEach? Break or return from Java 8 stream forEach? Feb 07, 2025 pm 12:09 PM

Java 8 introduces the Stream API, providing a powerful and expressive way to process data collections. However, a common question when using Stream is: How to break or return from a forEach operation? Traditional loops allow for early interruption or return, but Stream's forEach method does not directly support this method. This article will explain the reasons and explore alternative methods for implementing premature termination in Stream processing systems. Further reading: Java Stream API improvements Understand Stream forEach The forEach method is a terminal operation that performs one operation on each element in the Stream. Its design intention is

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP vs. Python: Understanding the Differences PHP vs. Python: Understanding the Differences Apr 11, 2025 am 12:15 AM

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP vs. Other Languages: A Comparison PHP vs. Other Languages: A Comparison Apr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP vs. Python: Core Features and Functionality PHP vs. Python: Core Features and Functionality Apr 13, 2025 am 12:16 AM

PHP and Python each have their own advantages and are suitable for different scenarios. 1.PHP is suitable for web development and provides built-in web servers and rich function libraries. 2. Python is suitable for data science and machine learning, with concise syntax and a powerful standard library. When choosing, it should be decided based on project requirements.

Get the gate.io installation package for free Get the gate.io installation package for free Feb 21, 2025 pm 08:21 PM

Gate.io is a popular cryptocurrency exchange that users can use by downloading its installation package and installing it on their devices. The steps to obtain the installation package are as follows: Visit the official website of Gate.io, click "Download", select the corresponding operating system (Windows, Mac or Linux), and download the installation package to your computer. It is recommended to temporarily disable antivirus software or firewall during installation to ensure smooth installation. After completion, the user needs to create a Gate.io account to start using it.

PHP's Impact: Web Development and Beyond PHP's Impact: Web Development and Beyond Apr 18, 2025 am 12:10 AM

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP: The Foundation of Many Websites PHP: The Foundation of Many Websites Apr 13, 2025 am 12:07 AM

The reasons why PHP is the preferred technology stack for many websites include its ease of use, strong community support, and widespread use. 1) Easy to learn and use, suitable for beginners. 2) Have a huge developer community and rich resources. 3) Widely used in WordPress, Drupal and other platforms. 4) Integrate tightly with web servers to simplify development deployment.

See all articles