private static int hexCharToNibble(char ch) {
    if (ch <= '9' && ch >= '0') {
      return ch - '0';
    } else if (ch >= 'a' && ch <= 'f') {
      return ch - 'a' + 10;
    } else if (ch >= 'A' && ch <= 'F') {
      return ch - 'A' + 10;
    }
    throw new IllegalArgumentException("Invalid hex char: " + ch);
  }
Convert a byte array into a hex string
hbase-common/src/main/java/org/apache/hadoop/hbase/util/Bytes.java