List of utility methods to do MD5
String | md5ToHex(byte[] hash) md To Hex StringBuilder hexString = new StringBuilder(); for (byte b : hash) { String hex = Integer.toHexString(0xFF & b); if (hex.length() == 1) { hexString.append('0'); hexString.append(hex); return hexString.toString(); |
String | md5ToString(byte[] md5sum) md To String StringBuilder sb = new StringBuilder(); for (int i = 0; i < md5sum.length; i++) { sb.append(Integer.toString((md5sum[i] & 0xff) + 0x100, 16).substring(1)); return sb.toString(); |
void | md5Update(byte[] inbuf, int inputLen) md Update int i, index, partLen; byte[] block = new byte[64]; index = (int) (count[0] >>> 3) & 0x3F; if ((count[0] += (inputLen << 3)) < (inputLen << 3)) count[1]++; count[1] += (inputLen >>> 29); partLen = 64 - index; if (inputLen >= partLen) { ... |
MessageDigest | newMd5() new Md try { return MessageDigest.getInstance("md5"); } catch (NoSuchAlgorithmException ex) { return null; |
String | newMD5HashUri(String value) new MD Hash Uri try { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] asBytes; try { asBytes = value.getBytes("UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); throw new IllegalStateException("unexpected", e); ... |
MessageDigest | newMd5MessageDigest() new Md Message Digest MessageDigest md; try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { throw new RuntimeException("Required MD5 message digest algorithm unavailable."); md.reset(); return md; ... |
boolean | validateMD5(String md5String) Returns true if the String could be a md5 if (md5String == null) { throw new IllegalArgumentException("md5String is null"); return md5String.length() == 32 && md5String.matches("([a-z0-9])+"); |