Java – Byte Array to Hex String

Another Quick Reference Code Snippet


StringBuilder tempString = new StringBuilder(2 * bytes.length);
    for (byte b : bytes) {
      tempString.append(“0123456789ABCDEF”.charAt((b & 0xF0) >> 4));
      tempString.append(“0123456789ABCDEF”.charAt((b & 0x0F)));
    }
    return tempString.toString();

Source:

http://stackoverflow.com/questions/5470219/java-get-md5-string-from-message-digest