MD5, md5 decryption

Source: Internet
Author: User

MD5, md5 decryption

1 public class MD5 {2 3 // Global Array 4 private final static String [] strDigits = {"0", "1", "2", "3 ", "4", "5", "6", "7", "8", "9", "a", "B", "c", "d ", "e", "f"}; 6 7 // return format: Numbers and strings 8 private static String byteToArrayString (byte bByte) {9 int iRet = bByte; 11 if (iRet <0) {12 iRet + = 256; 13} 14 int iD1 = iRet/16; 15 int iD2 = iRet % 16; 16 return strDigits [iD1] + strDigits [iD2]; 17} 18 19 // convert the byte array to a hexadecimal String of 20 private static String byteToString (byte [] bByte) {21 StringBuffer sBuffer = new StringBuffer (); 22 for (int I = 0; I <bByte. length; I ++) {23 sBuffer. append (byteToArrayString (bByte [I]); 24} 25 return sBuffer. toString (); 26} 27 28 public static String GetMD5Code (String strObj) {29 String resultString = null; 30 try {31 resultString = new String (strObj ); 32 MessageDigest md = MessageDigest. getInstance ("MD5"); 33 resultString = byteToString (md. digest (strObj. getBytes (); 34} catch (NoSuchAlgorithmException ex) {35 ex. printStackTrace (); 36} 37 return resultString; 38} 39}

 

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

11.11 Big Sale for Cloud

Get Unbeatable Offers with up to 90% Off,Oct.24-Nov.13 (UTC+8)

Get It Now >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.