private static String byteToHex(byte[] digest){
  StringBuilder builder=new StringBuilder();
  for (  byte b : digest) {
    String hex=Integer.toHexString(0xff & b);
    if (hex.length() == 1) {
      builder.append('0');
    }
    builder.append(hex);
  }
  return builder.toString();
}

private static String byteToHex ( byte [ ] digest ) { StringBuilder builder = new StringBuilder ( ) ; for ( byte b : digest ) { String hex = Integer . toHexString ( 0xff & b ) ; if ( hex . length ( ) == 1 ) { builder . append ( '0' ) ; } builder . append ( hex ) ; } return builder . toString ( ) ; }
transform binary to hex
