Summary Report of Java Programming Foundation project

Source: Internet
Author: User

Summary Report of Java Programming Foundation project

20135313 Wu Ziyi

I. Contents of the Project

Using the Java knowledge learned, do not call the Java Class Library, the implementation of cryptography related algorithm design, and complete the TDD test, design run interface.

Ii. Specific tasks

1, the requirements of the implementation of cryptographic algorithms include: symmetric cryptographic algorithm, asymmetric cryptographic algorithm, message digest algorithm.

2, required to complete the public class in each algorithm TDD test, test the code as much as possible, and should cover the special symbols, numbers, letters and other input characters.

3, the design of each password algorithm GUI interface, provide input and output area for the user input, view.

Iii. details of the plan

Week number

Schedule

Note

week5

Query the project contains information about each small block algorithm and how to implement it and the basics

Yuan Zheng Teacher's modern cryptography is still in the beginning, the knowledge of cryptography is not much, so the early query self-study task is heavier.

week6

Read the relevant content of "graphic cryptography".

Learn the theory of DES, AES, RSA, ElGamal, SHA-1, MD5.

week7

read about JAVA JCA, JCE, JSSE, JAAS in the art of Java encryption and decryption. Run debug queries to the code that can be downloaded without input and able to run.

Learn about the call of algorithm code and the input and output format of the program, and some basic operation of the design algorithm.

Week8

Preview the algorithm in modern cryptography: symmetric algorithm, asymmetric algorithm, digest algorithm, identity authentication four.

Previously, through the "Graphic cryptography" learned the basic ideas of each algorithm, this week, mainly through in-class textbooks on the specific mathematical basis and the calculation of each module detailed study.

Week9

Control the theoretical knowledge and programming data, design the implementation module of the algorithm.

No

Week10

Implementation of the symmetric algorithm 2.

That is, the DES, AES algorithm of the non-tuned class library.

Week11

Implementation of 2 asymmetric algorithms.

That is, the RSA, ElGamal algorithm of the non-tuned class library.

week12

implementation of the digest algorithm 2. And the implementation of the 6 password algorithm to modify, through the query library implementation of Java has encapsulated the cipher algorithm, the code written by the online programmer, draw on advanced statements, improve the code.

that is, the SHA-1 and MD5 algorithm of the non-tuned class library. and draw on the online cattle to share the open source code, the previously written basis of a single isolated class modified to include the inheritance, interface code block.

week13

Test the cryptographic algorithm using TDD unit tests and modify the part that does not pass the test.

week14

Learn the GUI and design the interface for the implemented cryptographic algorithms.

Find the GUI programming example, in the main function focus on the use of input, Output, select dialog box, simple design can provide to the user visual interface of the code.

Week15

The TDD test code is made tddsuit. The cipher algorithm code, TDD test code, and the main function of the algorithm with GUI interface are respectively called jar packages. Write the final project summary report.

No

Iv. Design Ideas

1, the project design at the beginning, through the "Modern cryptography" (in-class synchronization of teaching materials), "Graphic Cryptography" (extra-curricular supplementary learning materials) to understand the choice of the design of the cryptographic algorithm, the calculation process, the specific steps, the need for Mathematical theory.

2, according to the knowledge of cryptography, select the specific algorithm, according to the plan to achieve. These include: AES, DES, RSA, ElGamal, MD5, SHA-1 six cryptographic algorithms. Among them, the ElGamal, RSA algorithm contains its implementation of digital signature (belongs to its own expansion of the algorithm of expansion exercise) method.

3, in the programming process to develop the habit of commenting on the method, easy to modify the code when the clear search and the implementation of the algorithm to the public for use when the user form a help document.

4, in the design process, some methods or variables that do not need to be disclosed to private, such as:, and the introduction of inheritance, interface, etc. to reduce the coupling degree of the algorithm, to facilitate later optimization modification, such as:

5, in the design, occasionally try to use a single case design mode, but because of the Java design is not very skilled, the application is not very handy.

6, the design algorithm, according to different cryptographic algorithms used in the mathematical knowledge, must go to the online API to find the relevant classes and interfaces, choose to be able to do modulo exponentiation or Euler function values, generate random primes and other functions of the class to help me write the algorithm. Such as:

By looking up the API, all operations are known to represent BigInteger (such as the basic integer type of Java) in the form of a binary complement. BigInteger provides a counterpart to all Java's basic integer operators and provides all the relevant methods of Java.lang.Math. In addition, BigInteger provides the following operations: modulo arithmetic, GCD calculation, prime number test, prime generation, bit manipulation, and some other operations.

7, when writing the test code, coincides with the Java Course Experiment two is in progress, just have the opportunity to get started to learn TDD test, the person also downloaded the PDF data on the Internet (about JUnit unit test related operations, see report Reference), Choose to use the Assertequal assertion test statement to test the methods exposed in your code. Most of the methods to be tested are encryption methods and decryption methods. So just on-line on the site to decrypt, generate due to the encryption and decryption results, and their own encryption and decryption method to decrypt the same Mingmiven results to compare, you can obtain the TDD test results.

8, because of the eclipse code and the internal problems of the Windows system coding, sometimes need to modify the package encoding, but after querying the information on the Internet, found that there is still a problem with the addition and decryption of Chinese.

That is, the TDD unit test appears red bar, so there is no further learning to optimize.

9, when writing GUI interface, because the encryption and decryption algorithm does not exist too complex interface design, so only need to introduce the selection dialog box, input and Output Display dialog box. It's easier to teach yourself. Still trying to synthesize all cipher algorithms together to write the main function with GUI, design a multi-choice, simple and clear Java encryption and decryption engineering interface.

V. The process of realization

1. DES

(1) Include steps:

Given the 64bit clear text m, the M0 is arranged by a fixed initial permutation IP.

Perform 16 rounds of the same iterative operation, which is called the wheel function f.

The ciphertext C is obtained by using inverse permutation IP-1 for the bit string r16l16.

(2) List of methods:

It contains many private methods for the computation of many permutations and displacements, and for the conversion of the number of numbers in the encryption and decryption.

The only way to expose it is to encrypt (encrypt), decrypt (Dsencrypt), and get the key (Setkey), which is used to provide the user.

2. AES

(1) Algorithm steps

Subbytes (), Shiftrows (), Mixcolums (), AddRoundKey () four methods.

(2) method list

It contains four steps in the AES algorithm, corresponding to: Subbyte, Shift, mix, add and other shift, s box, the format of the numbers and other private methods. There are still only two methods of text and decryption in public.

3. RSA

(1) Algorithm steps

Find two different large prime p,q, calculated: N=pq,φ (n) = (p-1) (q-1), n public, φ (n) Confidential

Randomly generates an integer e, which is required to satisfy: 1<e<φ (n)-1, (E,φ (n)) =1

Applying the enclid algorithm to find D:

Public key K ' = (e,n), secret key K "=d, (E, d respectively called Crypto Exponent and decryption exponent)

(2) method list

All the computational modulo powers are encapsulated in calculated (), and the encryption and decryption methods are disclosed externally.

4, ElGamal

(1) Algorithm steps

Encryption algorithm: Set clear text is M,0≤m≤p, randomly select a positive integer k,gcd (k,p-1) = 1, calculate

Y1 (ciphertext) =GK mod p

Y2 (ciphertext) =MBK mod p

Decryption algorithm: M (plaintext) =y2/y1a Modp=mbk/gka=mgka/gka =m

(2) method list

5, MD5

(1) Algorithm steps

A. Fill

In the MD5 algorithm, the first need to fill the information, so that its bit length to 512 the result of the remainder is equal to 448, and the fill must be carried out, even if its bit length to 512 to find the result equals 448.

B. Initializing variables

The initial 128-bit value is the preliminary link variable, which is used for the first round of operations, expressed in the endian byte order.

C. Working with grouped data

The first group needs to copy the above four link variables into the other four variables: A to A, B to B,c to C,d to D. The variable starting from the second group is the result of the previous grouping, i.e. A = A, B = b, c = c, d = d.

Carry out a four-wheel main loop, and then move the resulting result to Zoo an indefinite number, plus one of a, B, C, or D. Finally, replace one of a, B, C or D with this result.

D. Output

(2) method list

The CalcMD5 () is the algorithm that asks for the message digest.

6, SHA-1

(1) Algorithm steps

Step one: Additional padding bits

Step Two: Additional length values

Step three: Initialize the MD cache

Step four: Processing 512-bit (16 words) packet sequence, the core of the algorithm is a module containing 4 "loops", each loop consists of 20 processing steps

Step Five: Output

(2) method list

Some non-linear functions, array formatting, number conversion and other private methods are included in the Message Digest, Getdigestofbytes (byte[]) is the method of seeking message digest.

Six, the main function package

Seven, test code package

Viii. Help Documentation

Nine, experience

In the Java Programming Foundation course participated in the project team, I in addition to follow the general classroom synchronization of Bi Xiangdong teacher Java video Teaching, More is self-study and application. My project is mainly to implement cryptography-related encryption and decryption algorithms and the algorithm of seeking message digest. Because the cryptography algorithm is more intuitive for the program running results, the correctness is more obvious. And I am personally interested in cryptography, so the application of Java Coding program is very powerful. But there are a lot of problems in this process. For example, during the encryption and decryption process, the resulting output is not the expected byte array. Again, for example, the algorithm for the addition and decryption of Chinese still have problems, for inheritance, single case and other applications are not proficient.

At the same time, I also learned more skills, such as the use of the TDD unit test introduced by Lou Teacher debugging code, the GUI interface design use, Code modularization idea, to the object-oriented understanding more deeply. Therefore, I think that in the process of participating in the project, although the pressure is greater, for cryptography algorithms, Java Learning progress and the intensity of the requirements are higher, but ultimately benefited.

X. outlook

1, the integration of various algorithms, placed in the same GUI interface.

2, the algorithm to reduce the coupling, more use of some inheritance, interface, single-case design.

Xi. Reference Documents

1.51CTO download-The way of Unit Test Java Edition: Using Junit.pdf

2. The art of encryption and decryption in Java (Second edition) mechanical industry Press present

3, "Modern Cryptography" (in-class teaching materials), Yuan Zheng Teacher teaching ppt

4, "Graphic Cryptography Technology"

Summary Report of Java Programming Foundation project

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.