MD5 algorithms are widely used in digital signature technology.
Digital Signature Technology: it can detect the integrity of files or other applications and determine whether there are any changes;
Simple application:
Assume that one end of the communication is the sender of the file, and the other end is the receiver of the file.
Sender: the sender calls related functions to generate the summary of the file, and then encrypts the summary with his/her private key, send the password mode of the digest information together with the file to the recipient;
Receiver: At this time, the receiver obtains two items: one is the required file and the other is the encrypted summary information. The receiver processes the following information,
First, use the public key provided by the sender to decrypt the encrypted digest information and restore the plaintext format of the digest information;
Then, the connected file performs function processing like the sender, and compares the obtained summary information with the decrypted summary information.
If the comparison results are the same, the accepted files are complete. If they are different, the files may have been modified or infected during transmission.
We can see from the above:Digital signature is actually an encryption process, while Digital Signature Verification is actually a decryption process..
The digital signature technology is widely used in software download sites, Forum databases, and system file security. For example, when we download a software, the MD5 value is often found in the description of the software for the download verification process, thus effectively preventing viruses.
MD5 is also widely used in login authentication of operating systems or general systems. For example, when we use a staff management system, it is found that the user password stored in the database table is not the original password format entered by the user, but a string after MD5 processing. When a user logs on, the system performs the MD5 hash operation on the password entered by the user, and compares it with the MD5 value in the database table to determine whether the entered password is correct. In this way, the password of a common user is not checked by a user with the system administrator permission. Even if the database is queried, only the information after MD5 processing is obtained.Abstract: The transition from information to source information is an irreversible process..
Work application:
Some time ago, I have been working on the Bank's nationwide image project. During the interaction between the Central Bank and commercial banks, the packet signing and signing process is actually the use of digital signatures, to ensure the integrity of message information.
Condition class: obtains the summary of a certain field of throttling.
Import Java. security. messagedigest; <br/> Import Java. security. nosuchalgorithmexception; </P> <p> public class md5util {</P> <p> Public String getmd5 (byte [] source) {<br/> string S = NULL; <br/> // used to convert bytes into hexadecimal characters <br/> char [] hexdigits = {'0', '1', '2 ', '3', '4', '5', '6', '7', '8', '9', <br/> 'A', 'B ', 'C', 'D', 'E', 'F'}; <br/> try {<br/> messagedigest MD = messagedigest. getinstance ("MD5"); <br/> Md. update (source); <br/> // the MD5 calculation result is a 128-bit long integer, expressed as 16 bytes <br/> byte [] TMP = md. digest (); <br/> // if each byte is expressed in hexadecimal notation, two characters are used (four characters in height and four characters in height ), therefore, it must be 32 characters in hexadecimal notation. <br/> char [] STR = new char [16*2]; <br/> int K = 0; // character position in the Conversion Result <br/> for (INT I = 0; I <16; I ++) {// convert each MD5 byte to a hexadecimal character <br/> byte byte0 = TMP [I]; <br/> STR [k ++] = hexdigits [byte0 >>> 4 & 0xf]; // perform hexadecimal conversion for the byte height of 4 bits <br/> STR [k ++] = hexdigits [byte0 & 0xf]; // perform hexadecimal conversion for the lower byte 4 bits <br/>}< br/> S = new string (STR); <br/>} catch (nosuchalgorithmexception E) {<br/> E. printstacktrace (); <br/>}< br/> return s; <br/>}< br/> Public static void main (string [] ARGs) {<br/> md5util md5util = new md5util (); <br/> string result = md5util. getmd5 ("ABC ". getbytes (); <br/> system. out. println (result); <br/>}</P> <p >}< br/>