docs: def encode(self, X, seed=None):
          """Given a string ``X``, returns ``unrank(X[:n]) || X[n:]`` where ``n``
          is the the maximum number of bytes that can be unranked w.r.t. the
          capacity of the input ``dfa`` and ``unrank`` is w.r.t. to the input
          ``dfa``.
          """
  
          if not X:
              return ''
  
          if not isinstance(X, str):
              raise InvalidInputException('Input must be of type string.')
  
          if seed is not None and len(seed) != 8:
              raise InvalidSeedLength('The seed is not 8 bytes long, seed length: '+str(len(seed)))
  
          ciphertext = self._encrypter.encrypt(X)
  
          maximumBytesToRank = int(math.floor(self.getCapacity() / 8.0))
          unrank_payload_len = (
              maximumBytesToRank - DfaEncoderObject._COVERTEXT_HEADER_LEN_CIPHERTTEXT)
          unrank_payload_len = min(len(ciphertext), unrank_payload_len)
  
          if unrank_payload_len <= 0:
              raise InsufficientCapacityException('Language doesn\'t have enough capacity')
  
          msg_len_header = fte.bit_ops.long_to_bytes(unrank_payload_len)
          msg_len_header = string.rjust(
              msg_len_header, DfaEncoderObject._COVERTEXT_HEADER_LEN_PLAINTEXT, '\x00')
          random_bytes = seed if seed is not None else fte.bit_ops.random_bytes(8)
          msg_len_header = random_bytes + msg_len_header
          msg_len_header = self._encrypter.encryptOneBlock(msg_len_header)
  
          unrank_payload = msg_len_header + \
              ciphertext[:maximumBytesToRank -
                  DfaEncoderObject._COVERTEXT_HEADER_LEN_CIPHERTTEXT]
  
          random_padding_bytes = maximumBytesToRank - len(unrank_payload)
          if random_padding_bytes > 0:
              unrank_payload += fte.bit_ops.random_bytes(random_padding_bytes)
  
          unrank_payload = fte.bit_ops.bytes_to_long(unrank_payload)
  
          formatted_covertext_header = self._dfa.unrank(unrank_payload)
          unformatted_covertext_body = ciphertext[
              maximumBytesToRank - DfaEncoderObject._COVERTEXT_HEADER_LEN_CIPHERTTEXT:]
  
          covertext = formatted_covertext_header + unformatted_covertext_body
  
          return covertext