Article From:https://www.cnblogs.com/wsj-wsj-wsj/p/9127640.html

2017-2018-2 20165309 experiment five” Java object-oriented programming “experimental report”

1, experimental principle

1. stack

  • The operation rule of the suffix is that the order of the operator in the formula is exactly the operation order of the expression; each operator and the two operands that appear before it and close to it constitute a minimum expression.
  • The suffix type can be used by the infix form, and the pseudo code is as follows:
    • Set up a stack and store the operator. First, the stack is empty.
    • Scan the infix form from left to right. If the operand is encountered, output directly, and output a space as the separator of the two operands.
    • If the operator is encountered, the stack is higher than the top of the stack, which is higher than the top level of the stack. Otherwise, it will exit the top element of the stack and output, and then output a space as a separator.
    • If you encounter the left parenthesis, enter the stack; if you encounter the right brackets, you will continue to stack and output until the left bracket.
    • When the stack becomes empty, the result of output is suffix expression.
  • LinuxlowerdcOperator:
    • +: W1 and W2 are popped in turn, and the w2+w1 stack is pressed. Precision is the result value precision
    • -: W1 and W2 are popped out in turn, and the w2-w1 stack is pressed
    • *: W1 and W2 are popped in turn, and the w2*w1 stack is pressed. Precision is the result value precision and the larger value in precision
    • /: W1 and W2 are popped in turn, and the w2/w1 stack is pressed. The precision is precision

2. socket”

  • Network socket is based on TCP protocol with connection communication.
  • Socket connection is client socket object and server-side socket object connected by input stream and output stream.
  • The server builds the ServerSocket object, and the ServerSocket object is responsible for waiting for the client to request a socket connection, and the client establishes a Socket object to send a socket connection request to the server.
  • To create a socket, you can use Socket’s construction methods, such as:public Socket(java.lang.String host, int port)。Among them, host is the remote machine name or IP address, and port is the port number of the remote application.

3.Java cryptology algorithm”

> two, the content of the experiment

1. network programming and security -1

Function of pair to implement infix expression to suffix expression MyBC.java

The pair realizes the function of evaluating the suffix expression in the expression obtained from the above function, and calls MyDC.java.

  • The test code runs as follows

2. network programming and security -2

The client / server function is implemented based on Java Socket, and the transmission mode is TCP.

The client lets the user enter the infix expression, and then transforms the function of the infix expression called MyBC.java into a suffix expression, sending the suffix expression to the server through the network

The server receives the suffix expression, calls the function of MyDC.java to calculate the value of the suffix expression, and sends the result to the client.

The client displays the results sent by the server

  • Client
  • The server

3. network programming and security -3

The client / server function is implemented based on Java Socket, and the transmission mode is TCP.

The client lets the user input the infix expression, and then transforms the function of the infix expression called MyBC.java into a suffix expression, and the suffix expression is encrypted with the 3DES or AES algorithm to send the ciphertext to the server through the network.

The server receives the suffix expression expression, declassified (the key to the client, can be saved in an array), and then invokes the function of the MyDC.java to calculate the value of the suffix expression and send the result to the client.

The client displays the results sent by the server

  • Client
  • The server

4. network programming and security -4

The client / server function is implemented based on Java Socket, and the transmission mode is TCP.

The client lets the user input the infix expression, then transforms the function of the infix expression called MyBC.java into a suffix expression, and sends the suffix expression to the server via the network to send the ciphertext to the server via the network or the AES algorithm.

The client and server use the DH algorithm to carry out the key exchange between 3DES or AES algorithm.

After receiving the expression of the suffix expression, the server decrypts, then invokes the function of MyDC.java to calculate the value of the suffix expression and sends the result to the client.

The client displays the results sent by the server

  • Client
  • The server

5. network programming and security -5

The client / server function is implemented based on Java Socket, and the transmission mode is TCP.

The client lets the user enter the infix expression, and then transforms the function of the infix expression called MyBC.java into a suffix expression, and the suffix expression is encrypted by 3DES or AES algorithm to send the encrypted and plaintext MD5 to the server through the network.

The client and server use the DH algorithm to carry out the key exchange between 3DES or AES algorithm.

After receiving the expression expression of the suffix, the server decrypts, decrypts the MD5 value of the plaintext, compares it with the MD5 from the client, and calls the function of the MyDC.java to calculate the value of the suffix expression and send the result to the client.

The client displays the results sent by the server

  • Client
  • The server

three, problems encountered in the experiment and Solutions

  • Problem: the mistake is as follows
  • Solution: change the individual port number.

four, experiment harvest

The part I was responsible for in this experiment was the server, and the whole process was very difficult for me. I had to learn a lot of the blogs of the elder sister and rely on a lot of Baidu and slow down the progress of the partner. In a word, the thirteen chapter is very important.

steptime consumingPercentage
requirement analysis20min7.4
Design60min22.2
code implementation120min44.4
test40min14.9
Analysis and summary30min11.1

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *