@Test public void testComputeMD5Hash () { String text = "text"; String expectedMD5Hash = "1cb251ec0d568de6a929b520c4aed8d1"; String hash = HashUtils.computeMD5Hash(text); assertEquals(expectedMD5Hash, hash); }
public static String computeMD5Hash(String password) { StringBuilder md5Hash = new StringBuilder(); try { MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(password.getBytes()); byte[] messageDigest = digest.digest(); for (int i = 0; i < messageDigest.length; i++) { String h = Integer.toHexString(0xFF & messageDigest[i]); while (h.length() < 2) h = "0" + h; md5Hash.append(h); } } catch (NoSuchAlgorithmException e) { Log.e(LOG_TAG, "NoSuchAlgorithmException: ", e); e.printStackTrace(); } return md5Hash.toString(); }
HashUtils { public static String computeMD5Hash(String password) { StringBuilder md5Hash = new StringBuilder(); try { MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(password.getBytes()); byte[] messageDigest = digest.digest(); for (int i = 0; i < messageDigest.length; i++) { String h = Integer.toHexString(0xFF & messageDigest[i]); while (h.length() < 2) h = "0" + h; md5Hash.append(h); } } catch (NoSuchAlgorithmException e) { Log.e(LOG_TAG, "NoSuchAlgorithmException: ", e); e.printStackTrace(); } return md5Hash.toString(); } }
HashUtils { public static String computeMD5Hash(String password) { StringBuilder md5Hash = new StringBuilder(); try { MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(password.getBytes()); byte[] messageDigest = digest.digest(); for (int i = 0; i < messageDigest.length; i++) { String h = Integer.toHexString(0xFF & messageDigest[i]); while (h.length() < 2) h = "0" + h; md5Hash.append(h); } } catch (NoSuchAlgorithmException e) { Log.e(LOG_TAG, "NoSuchAlgorithmException: ", e); e.printStackTrace(); } return md5Hash.toString(); } protected  HashUtils(); }
HashUtils { public static String computeMD5Hash(String password) { StringBuilder md5Hash = new StringBuilder(); try { MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(password.getBytes()); byte[] messageDigest = digest.digest(); for (int i = 0; i < messageDigest.length; i++) { String h = Integer.toHexString(0xFF & messageDigest[i]); while (h.length() < 2) h = "0" + h; md5Hash.append(h); } } catch (NoSuchAlgorithmException e) { Log.e(LOG_TAG, "NoSuchAlgorithmException: ", e); e.printStackTrace(); } return md5Hash.toString(); } protected  HashUtils(); static String computeSHAHash(String password); static String computePasswordSHAHash(String password); static String computeMD5Hash(String password); static String computeMD5FileHash(File file); }
HashUtils { public static String computeMD5Hash(String password) { StringBuilder md5Hash = new StringBuilder(); try { MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(password.getBytes()); byte[] messageDigest = digest.digest(); for (int i = 0; i < messageDigest.length; i++) { String h = Integer.toHexString(0xFF & messageDigest[i]); while (h.length() < 2) h = "0" + h; md5Hash.append(h); } } catch (NoSuchAlgorithmException e) { Log.e(LOG_TAG, "NoSuchAlgorithmException: ", e); e.printStackTrace(); } return md5Hash.toString(); } protected  HashUtils(); static String computeSHAHash(String password); static String computePasswordSHAHash(String password); static String computeMD5Hash(String password); static String computeMD5FileHash(File file);  }