MD5 Encryption--java Code

Source: Internet
Author: User

1  Public classStringToMD5 {2 3     Private StaticStringBuffer Sbuffer;4 5      Public Staticstring Getmd5code (String str) {6 MessageDigest MD;7         Try {8             //md.digest () The function returns a byte array that holds the result of the hash value9MD = Messagedigest.getinstance ("MD5");Ten             byte[] Md5bytes =md.digest (Str.getbytes ()); OneSbuffer =NewStringBuffer (); A              for(inti = 0; i < md5bytes.length; i++) { -                 intval = ((int) Md5bytes[i]) & 0xFF; -                 if(Val < 16) theSbuffer.append ("0"); - Sbuffer.append (Integer.tohexstring (Val)); -             } -             returnsbuffer.tostring (); +}Catch(nosuchalgorithmexception e) { - e.printstacktrace (); +         } A         return""; at     } -}

For these are not very understanding of the system (class is not serious), I am afraid to write misleading everyone, think of a half-day write a half-day or delete, know what meaning is unable to express, the method is so, the specific meaning why only to ask a master

MD5 Encryption--java Code

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.