Android MD5 Encryption Algorithm

Source: Internet
Author: User

Android MD5 encryption is the same as j2se, because Android supports Java. Security. messagedigest. Actually, it is exactly the same as the j2se platform.

Algorithm signature:

String getmd5 (string Val) throws nosuchalgorithmexception

Enter a string (the text to be encrypted) to obtain an encrypted output string (the encrypted text)

Package COM. tencent. utils; import Java. security. messagedigest; import Java. security. nosuchalgorithmexception;/*** provides the getmd5 (string) Method * @ author randyjia **/public class MD5 {public static string getmd5 (string Val) throws nosuchalgorithmexception {messagedigest MD5 = messagedigest. getinstance ("MD5"); md5.update (Val. getbytes (); byte [] M = md5.digest (); // encrypted return getstring (m);} Private Static string getstring (byte [] B) {stringbuffer sb = new stringbuffer (); For (INT I = 0; I <B. length; I ++) {sb. append (B [I]);} return sb. tostring ();}}


Related Article

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: 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.