Back to project page SimpleReader.
The source code is released under:
Apache License
If you think the Android project SimpleReader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.dreamteam.app.utils; /*from w w w. ja v a 2 s . c o m*/ import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class MD5 { public static String Md5(String str) { if (str != null && !str.equals("")) { try { MessageDigest md5 = MessageDigest.getInstance("MD5"); char[] HEX = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; byte[] md5Byte = md5.digest(str.getBytes("UTF8")); StringBuffer sb = new StringBuffer(); for (int i = 0; i < md5Byte.length; i++) { sb.append(HEX[(int) (md5Byte[i] & 0xff) / 16]); sb.append(HEX[(int) (md5Byte[i] & 0xff) % 16]); } str = sb.toString(); } catch(NoSuchAlgorithmException e) { } catch(Exception e) { } } return str; } }