20135333 Experimental Report of Su Zhengshen experiment

Source: Internet
Author: User

Course:

Java programming

Class:

1353

Name:

Su Zhengshen

School Number:

2015333

Results:

Instructor:

Lou Jia Peng

Date of experiment:

2015.6.9

Experimental classification:

Preview level:

Experiment Time:

3:20~5:00

Instrument Group Times:

Compulsory / Elective:

Compulsory

Experiment Serial Number:

Experiment Four

Experiment Name:

Java Network Programming and security
Experimental content: 1. Master the socket program writing; 2. Mastering the use of cryptographic technology; 3. Design a secure transmission system.

Experimental instrument:

Name

Model

Number

Notebook PC

Msi GS70

1

Experiment Preparation:

This experiment was carried out by two pairs programming, before the experiment, I (20135333) and Zheng Wei (20135322) formed a group

Division of Labor: Su Zhengshen--Server program writing debugging, and data decryption, digest verification

Zheng Wei--Client program writing debugging, and data encryption, key delivery Blog Link:

http://www.cnblogs.com/zhengwei0712/Experimental steps: 1. Secure transmission based on Java sockets

Sockets are Api,socket interfaces for TCP/IP networks that define a number of functions or routines that programmers can use to develop applications on TCP/IP networks.

2. Implementation of client and server based on TCP, pair programming one person is responsible for the client, one person is responsible for the server

Server: Use ServerSocket to listen to the specified port, the port can be arbitrarily specified, wait for the client connection request, after the client connects, the session is generated; After the session is completed, the connection is closed. Where the server process that creates the bound port is successfully returned when the client process's socket construction method returns, the connection request that represents the client process is joined to the server process's request connection queue. Although the client successfully returned the socket object, it did not form a communication line with the server process. The server process must take a connection request from the request Connection queue and return a socket object after the server process passes the ServerSocket's accept () method, which forms a communication line with the client's socket object.

The server obtains the input stream and output stream from the Socket object and can exchange data with the customer. When the server is in the operation of sending data, if the client disconnects, then the server side throws a IOException subclass SocketException exception.

3. Use Git for version control 4. Select the symmetric algorithm for data encryption and decryption.

In this experiment, our team adopted RSA Public key cryptography, which is relatively a high security encryption method.

5. Select the asymmetric algorithm to distribute the key for the symmetric encryption key.

Keygenerator kg=keygenerator.getinstance ("Desede");
Kg.init (168);
Secretkey K=kg.generatekey ();
Byte[] ptext2=k.getencoded ();
String Kstr=parsebyte2hexstr (KB);

6. Select the MD5 algorithm for integrity verification.
                        String x=s; MessageDigest m2=messagedigest.getinstance ("MD5"); M2.update (X.getbytes ()); byte a[]=m2.digest (); String result= ""; for (int i=0; i<a.length; i++) {                                result+=integer.tohexstring (0x000000ff & A[i]) | 0XFFFFFF00). substring (6);} SYSTEM.OUT.PRINTLN (result); Out.println (result);     

  

        String Aline3=in.readline (); String x=p; MessageDigest m2=messagedigest.getinstance ("MD5");         M2.update (X.getbytes ());         byte a[]=m2.digest ();         String result= "";         for (int i=0; i<a.length; i++) {            result+=integer.tohexstring ((0X000000FF & A[i]) | 0xffffff00). SUBSTRING (6);     }         SYSTEM.OUT.PRINTLN (result); if (aline3.equals (Result)) {System.out.println ("match succeeded");
Experimental results:

Experiment Experience:

The key code of this program can be written in the reference book of the algorithm. The operation of the data flow is largely the same whether it is a client or a server. At the same time, the algorithm and application of many cryptographic cryptography techniques are given the complete display in code, which is advantageous to the operation.

This design is the server and client communication between, the teacher in our design before the explanation is very clear, so that we all operate more skilled. Let me feel the interesting and practical software programming, although some of the technology we have learned in the classroom, but mostly stay on the theoretical basis, the actual development is very few, and this experiment gave us a good learning side of the practice of the opportunity, to our deep learning these technologies have a great help, The practicality of these technologies has been deeply realized.

Through this experiment, I learned a lot more about Java programming and operation, in later experiments and practical operation, I believe I can better use Java to write Java program, at the same time for Socke programming and secure transmission has a new understanding.

Reference to Problem solving:

What 1.socket programming is.
Http://zhidao.baidu.com/link?url=qdcZMpAjpF0sxJo3Jd2iNCBZfl9QYeN2cbF5WGMvyq3qX-CWSUw1EGKKlmey7kKfinySkUCsQdQ4loJ8JNknk_

2.

Analysis on the principle and application of MD5 algorithm

Wenku.baidu.com/link?url= 0oruxrax2z7zzlqdihy56hhevnwwssfarijnywz5x8jlw-trxhgtlb6frnzy7idmjsvdm7tyi5q5gydaqmtzlpi58gssbjzphd-tvqif1wg
Http://wenku.baidu.com/link?url= 0oruxrax2z7zzlqdihy56hhevnwwssfarijnywz5x8jlw-trxhgtlb6frnzy7idmjsvdm7tyi5q5gydaqmtzlpi58gssbjzphd-tvqif1wg

3.ServerSocket usage Details (i)-lin49940 's Column-Blog channel-csdn.net

http://blog.csdn.net/lin49940/article/details/4398364

20135333 Experimental Report of Su Zhengshen experiment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.