Android examples for java.security:MD5
Generate MD5 for String
import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; public class Main { public static String parseStringToMD5(String str) { StringBuffer sb = new StringBuffer(); try {/*from w ww .j a v a 2s. com*/ MessageDigest md5 = MessageDigest.getInstance("MD5"); byte[] bytes = md5.digest(str.getBytes()); for (int i = 0; i < bytes.length; ++i) { sb.append(Integer.toHexString((bytes[i] & 0xFF) | 0x100).substring(1, 3)); } } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } return sb.toString(); } }