For China, although many foreign equipment can be imported, encryption equipment can't be imported, because it involves network security and the security of state secret information, so it is necessary to develop its own encryption algorithm, including DES (Data Encryption Standard) internationally. It is the earliest and most widely used block symmetric encryption algorithm DES. It encrypts the plaintext with the bit honey key, and the bit key * * * of the output bit ciphertext DES has a possible key, but the DES key has been cracked by exhaustive attacks in history. The special computer made in ten thousand yuan cracked the DES key within hours, and EFF has to finish the cracking work within hours every year, which has severely hit the DES algorithm and seriously threatened its security, because the security of JAVA language and the network processing ability are very strong. This paper mainly introduces the use of IDEA (Internal Data Encryption Algorithm) data encryption algorithm to realize the safe transmission of data in Java environment.
An ideal data encryption algorithm
The IDEA data encryption algorithm was jointly proposed by China scholar Dr. Xue Jia and famous cryptographer James L. Marcy in. Its plaintext and ciphertext are bits, but the key length is bits. IDEA is implemented as an iterative block cipher, which uses key bits and periods, and provides higher security than des, but these factors should be excluded when choosing the key for IDEA. The key DES called weak key has only four weak keys and a second weak key, but the number of weak keys in the IDEA is a considerable power. However, if the total number of keys is very large, there are still power keys to choose from. The idea is considered extremely safe. Compared with DES, the number of tests required for brute force attacks using bits will increase significantly, and even weak keys are allowed to be tested, which shows that it is particularly resistant to professional analysis attacks.
Second, Java password system and Java password extension
Java is an object-oriented programming language developed by Sun Company. Because of its platform independence, it is widely used in the development of Java Cryptosystem (JCA) and Java Cryptosystem Extension (JCE) on the Internet. The purpose of the design is to provide an implementation-independent encryption function API for Java. They are routines that create classes by factory methods, and then delegate the actual encryption function to the underlying engine designated by the provider, which provides a service provider interface for the class. Data encryption/decryption in Java is realized by using its built-in JCE(Java Encryption Extension). The Java development tool set implemented by provides a new and flexible application programming interface based on suppliers, which is used to realize encryption functions, including digital signature and information summarization. Java cryptographic architecture supports the interoperability of vendors and the implementation of software and hardware. The design of Java cryptographic architecture follows two principles: (1) independence and reliability of the algorithm (2). The independence and interactivity of encryption algorithm are obtained by defining encryption service class. Users only need to understand the concepts of cryptographic algorithms, and do not need to care about how to realize the independence and interactivity of these concepts. A cryptographic service provider is one or more packages that implement one or more cryptographic services. Software developers package various algorithms into a provider according to a certain interface, which users can install. Use different providers to install and configure providers. You can put the ZIP and JAR files containing providers in the classpath, and then edit the Java security properties file to set the default provider Sun when defining the Sun version of the provider Java runtime environment.
Implementation in Java environment
Implementation of encryption process
Void idea_enc( int data [] /* first address of bit data to be encrypted */intkey []) {int i; int tmp x; int ZZ[]= new int[]; for(I =; I <; I+=){/* Round cycle */for(int j = box = I; j & lt; j++ box++){ ZZ[j]= key[box]; } x = handle_data (data ZZ); tmp = data[]; /* Exchange the middle two */data [] = data []; data[]= tmp; } tmp = data[]; /* There was no exchange in the last round */data [] = data []; data[]= tmp; data[]= MUL(data[]key[]); data[]=(char)((data[]+key[])% x); data[]=(char)((data[]+key[])% x); data[]= MUL(data[]key[]); }
Realization of decryption process
Voidkey _ decrypt exp (int out key [])/* Inverse processing of decryption key */{int tmpkey [] = new int []; int I; for(I =; I <; i++){ tmpkey[I]= out key[wz _ sp key[I]]; /* transposation */} for(I =; I <; i++){ out key[I]= tmp key[I]; } for(I =; I <; i++){ out key[wz _ spaddrever[I]]=(char)(out key[wz _ spaddrever[I]]); /* Replace with addition inverse */} (i =; I <; i++){ out key[wz _ spmulrevr[I]]=(char)(mulinuv(out key[wz _ spmulrevr[I]])); /* Replace with multiplication inverse operation */}}
Four summaries
Lishi Xinzhi/Article/program/Java/hx/20 13 1 1/27228