MD5 algorithm is widely used in digital signature technology
Digital signature technology: can detect the integrity of files or other applications, judge whether there is modification;
The simple application is as follows:
Assume that the end of the communication is the sender of the file, and the other end is the recipient of the file.
Sender: The sender to the sent file call related functions to generate the summary information of the file, and then the summary information with its own private key for encryption processing, the summary information password mode with the file sent to the receiver;
Accept-side: At this point, the receiver has two things, one is the required file, the other is the encrypted digest information, the receiving end is processed as follows,
First, the encrypted digest information is decrypted by using the public key provided by the sender, and the plaintext format of the summary information is restored.
The received file is then processed like a transmitter, and the resulting summary information is compared to the decrypted summary information.
If the result is the same, the accepted file is complete and, if different, the file may have been modified or infected during transmission.
As can be seen from the above: digital signature is actually a process of encryption, and the verification of digital signature is actually a decryption process .
Digital signature technology is widely used in software download station, forum database, System file security, such as: When we download a software, often in the description of the software to find its MD5 value for download after the verification process, so as to effectively prevent the virus.
MD5 is also commonly used in operating systems or general system login authentication, such as when we develop the use of personnel management system, found that the database table stored in the user password is not the user entered the original ecological password format, but after the MD5 processing a section of string. When the user logs in, the system MD5 the user's password into a hash operation and compares the MD5 value in the database table to determine if the password is correct. This avoids the ordinary user's password is to have the system Administrator authority user to check, even if the database, obtains is only the MD5 processing information, but the summary information transforms to the source information is an irreversible process .
Work application:
has been in the bank of the national image of the project, in the central bank and commercial banks in the process of image interaction, involving the message of the signing, the process of nuclear signing, but also the use of digital signature process, in order to ensure the integrity of message information.
Utility class: Get summary information for a byte stream
Import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Md5util {public String getMD5 (byte[] Source {string s=null;//characters used to convert bytes into a 16-binary representation char[] hexdigits={' 0 ', ' 1 ', ' 2 ', ' 3 ', ' 4 ', ' 5 ', ' 6 ', ' 7 ', ' 8 ', ' 9 ', ' A ', ' B ', ' C ', ' d ', ' e ', ' f '}; try {messagedigest md=messagedigest.getinstance ("MD5"); md.update (source);//md5 evaluates to a 128-bit long integer, expressed in bytes as 16 bytes byte[] Tmp=md.digest (); Each byte is expressed in 16, using 2 characters (4 bits high, 4 bits a lower), so the 16-character char[] Str=new char[16*2]; int k=0;//the corresponding character position in the result (int i=0;i<16;i++) {//convert each byte of MD5 into a 16-character Byte byte0=tmp[i]; str[k++]=hexdigits[byte0 >>>4 & 0xf];//16 conversion to byte High 4 bits str[k++]=hexdigits[byte0 & 0xf]; 16-s=new String (str) for byte low 4 bits; catch (NoSuchAlgorithmException e) {e.printstacktrace ();} return s; public static void Main (string[] args) {md5util md5util=new md5util (); String RESULT=MD5UTIL.GETMD5 ("abc". getBytes ()); SYSTEM.OUT.PRINTLN (result); } }