Wemall App Store source Android Development MD5 Encryption Tool class

Source: Internet
Author: User

Wemall-mobile is based on the Wemall Android App Store, only need to upload the interface file in the original mall directory to complete the server configuration, the client can be customized modification. This article shares the main code of the Android Development MD5 encryption tool class for technician reference learning.

Package Com.gzcivil.utils;import Java.io.unsupportedencodingexception;import Java.security.messagedigest;import Java.security.nosuchalgorithmexception;public class Md5tool {public static string MD5 (String string) {byte[] H        Ash        try {hash = messagedigest.getinstance ("MD5"). Digest (String.getbytes ("UTF-8"));        } catch (NoSuchAlgorithmException e) {throw new RuntimeException ("Huh, MD5 should be supported?", e);        } catch (Unsupportedencodingexception e) {throw new RuntimeException ("Huh, UTF-8 should be supported?", e);        } StringBuilder hex = new StringBuilder (Hash.length * 2);            for (byte B:hash) {if ((b & 0xFF) < 0x10) Hex.append ("0");        Hex.append (integer.tohexstring (b & 0xFF));    } return hex.tostring ();        public static string encrypt (string data) {if (data = = NULL) data = "";        byte[] Btret = null;     try {       Btret = _encrypt (Data.getbytes ("Utf-8"));        } catch (Unsupportedencodingexception e) {e.printstacktrace ();        } if (Btret = = null) return null;    Return Binstr.byte2str (Btret). toLowerCase ();     }/** * Encrypt MD5 * * @param content * requires encrypted contents * @param password * Encrypt password             * @return */private static byte[] _encrypt (byte[] btdata) {try {//MD5 object to get MessageDigest digest algorithm            MessageDigest mdinst = messagedigest.getinstance ("MD5");            Updates the digest mdinst.update (btdata) using the specified byte;        Get ciphertext return mdinst.digest ();            } catch (Exception e) {e.printstacktrace ();        return null; }    }         }

  

Original Details Address: http://git.oschina.net/einsqing/wemall-mobile

Wemall-mobile Mall details Address: http://www.koahub.com/home/product/56

Wemall website Address: http://www.wemallshop.com

Wemall-Open Source Micro-Mall Mall Mall Source Distribution Mall B2B2C Mall system

Wemall App Store source Android Development MD5 Encryption Tool class

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.