code: public static String toHexString(BigInteger b) {
          String hexValue = b.toString(16);
          StringBuffer buf = new StringBuffer(hexValue.length()*2);
  
          if (hexValue.startsWith("-")) {
              buf.append("   -");
              hexValue = hexValue.substring(1);
          } else {
              buf.append("    ");     // four spaces
          }
          if ((hexValue.length()%2) != 0) {
              // add back the leading 0
              hexValue = "0" + hexValue;
          }
          int i=0;
          while (i < hexValue.length()) {
              // one byte at a time
              buf.append(hexValue.substring(i, i+2));
              i+=2;
              if (i!= hexValue.length()) {
                  if ((i%64) == 0) {
                      buf.append("\n    ");     // line after eight words
                  } else if (i%8 == 0) {
                      buf.append(" ");     // space between words
                  }
              }
          }
          return buf.toString();
      }
docs: return a hexadecimal printed representation of the specified
  BigInteger object. the value is formatted to fit on lines of
  at least 75 characters, with embedded newlines. Words are
  separated for readability, with eight words (32 bytes) per line.