MD5 algorithm principle

Source: Internet
Author: User
// Message Digest: processes an array of characters of any length into an array of characters of a fixed length. It is used to ensure that the original string is not modified. // You can also use the password for confirmation. If the password is the same, the values generated by MD5 must be consistent. Otherwise, different public class datautil {public static void main (string [] ARGs) throws exception {char [] CH = {'0 ', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A ', 'B', 'C', 'D', 'E', 'F',}; string src = "Tang"; stringbuffer sb = new stringbuffer (); byte [] b1 = SRC. getbytes (); system. out. println ("-----------" + b1.length); For (byte B: B1) {system. out. print (B + "");} system. out. println (); messagedigest MD = messagedigest. getinstance ("MD5"); byte [] b2 = md. digest (B1); system. out. println ("-------" + b2.length); For (byte B: B2) {system. out. print (B + ""); // the four-digit sb. append (CH [B> 4 & 0x0f]); // four-bit sb. append (CH [B & 0x0f]);} system. out. println (); system. out. println (sb. length () + ":" + sb. tostring ());}}

 

MD5 algorithm principle

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.