code: private static void updateLengthAndBytes(MessageDigest digest, ByteBuffer binaryValue) {
          ByteBuffer readOnlyBuffer = binaryValue.asReadOnlyBuffer();
          int size = readOnlyBuffer.remaining();
          ByteBuffer lengthBytes = ByteBuffer.allocate(INTEGER_SIZE_IN_BYTES).putInt(size);
          digest.update(lengthBytes.array());
          digest.update(readOnlyBuffer);
      }
docs: Update the digest using a sequence of bytes that consists of the length (in 4 bytes) of the
  input ByteBuffer and all the bytes it contains.