44.Android Md5util

Source: Internet
Author: User

44.Android Md5util
 Public classMd5util { Public StaticStringgetmd5string(String key) {CharHexdigits[] = {' 0 ',' 1 ',' 2 ',' 3 ',' 4 ',' 5 ',' 6 ',' 7 ',' 8 ',' 9 ',' A ',' B ',' C ',' D ',' E ',' F '};Try{byte[] input = Key.getbytes ();//MessageDigest object for MD5 algorithmMessageDigest md5digest = messagedigest.getinstance ("MD5");//ConversionMd5digest.update (input);//Cipher            byte[] Md5byte = Md5digest.digest ();//String to hex            intj = md5byte.length;CharMd5char[] =New Char[J *2];intK =0; for(byteB:md5byte) {md5char[k++] = hexdigits[b >>>4&0xf]; md5char[k++] = hexdigits[b &0xf]; }return NewString (Md5char); }Catch(Exception e) {E.printstacktrace ();return NULL; }    }Private StaticStringbytestohexstring(byte[] bytes) {StringBuilder SB =NewStringBuilder (); for(byteabyte:bytes) {String hex = integer.tohexstring (255& Abyte);if(hex.length () = =1) {Sb.append (' 0 ');        } sb.append (hex); }returnSb.tostring (); }}

44.Android Md5util

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.