Given a message, return its globally-unique key.

        Parameters:
          message(Message)

        Returns:
          str
345516
def build_message_key(self, message) -> str:
        
        message_key = "%(namespace)s:%(queue_name)s:%(actor_name)s:%(message_id)s" % {
            "namespace": self.namespace,
            "queue_name": q_name(message.queue_name),
            "actor_name": message.actor_name,
            "message_id": message.message_id,
        }
        return hashlib.md5(message_key.encode("utf-8")).hexdigest()
1246606
def message(message, title=''):
    
    return backend_api.opendialog("message", dict(message=message, title=title))
1111637
def encode(self, message):
        ''''''
        if not isinstance(message, dict):
            message = {'message': message}
        message['time'] = time.time()
        return json.dumps(message)
1106352
def ProcessMessage(self, message):
    
    cert = rdf_crypto.Certificate(message.payload)

    queue = self.well_known_session_id.Queue()

    client_id = message.source

    # It makes no sense to enrol the same client multiple times, so we
    # eliminate duplicates. Note, that we can still enroll clients multiple
    # times due to cache expiration.
    try:
      enrolment_cache.Get(client_id)
      return
    except KeyError:
      enrolment_cache.Put(client_id, 1)

    # Create a new client object for this client.
    if data_store.AFF4Enabled():
      client = aff4.FACTORY.Create(
          client_id, aff4_grr.VFSGRRClient, mode="rw", token=self.token)
      client_cert = client.Get(client.Schema.CERT)

    if data_store.RelationalDBEnabled():
      try:
        md = data_store.REL_DB.ReadClientMetadata(client_id.Basename())
        client_cert = md.certificate
      except db.UnknownClientError:
        client_cert = None

    if data_store.RelationalDBEnabled():
      data_store.REL_DB.WriteClientMetadata(
          client_id.Basename(), fleetspeak_enabled=False)

    # Only enroll this client if it has no certificate yet.
    if not client_cert:
      # Start the enrollment flow for this client.

      # Note, that the actual CAEnroler class is autogenerated from the
      # CAEnrolerMixin by the DualDBFlow decorator confusing the linter - hence
      # the disable directive.
      flow.StartAFF4Flow(
          client_id=client_id,
          flow_name=CAEnroler.__name__,  # pylint: disable=undefined-variable
          csr=cert,
          queue=queue,
          token=self.token)
1008770
def get_input_message(message):
    """"""
    try:
        if isinstance(message, int):  # This case is really common too
            return types.InputMessageID(message)
        elif message.SUBCLASS_OF_ID == 0x54b6bcc5:  # crc32(b'InputMessage'):
            return message
        elif message.SUBCLASS_OF_ID == 0x790009e3:  # crc32(b'Message'):
            return types.InputMessageID(message.id)
    except AttributeError:
        pass

    _raise_cast_fail(message, 'InputMedia')
255948
protected function unique($key, $message)
        {
            return !isset($this->messages[$key]) || !Arrays::in($message, $this->messages[$key]);
        }
625194
def decrypt(self, message):
        

        # Unserialize the encrypted message
        message = json.loads(message)

        # Set up a list for the unencrypted lines of the message
        unencrypted_msg = []

        for line in message:

            # Convert from ascii back to bytestring
            enc_line = binascii.a2b_base64(line)

            # Decrypt the line using our private key
            unencrypted_line = rsa.decrypt(enc_line, self.private_key)

            unencrypted_msg.append(unencrypted_line)

        # Convert the message from a list back into a string
        unencrypted_msg = "".join(unencrypted_msg)

        return unencrypted_msg
215005
def signMessage(self, message):
        
        if (message.hasKey(OPENID_NS, 'sig') or
            message.hasKey(OPENID_NS, 'signed')):
            raise ValueError('Message already has signed list or signature')

        extant_handle = message.getArg(OPENID_NS, 'assoc_handle')
        if extant_handle and extant_handle != self.handle:
            raise ValueError("Message has a different association handle")

        signed_message = message.copy()
        signed_message.setArg(OPENID_NS, 'assoc_handle', self.handle)
        message_keys = signed_message.toPostArgs().keys()
        signed_list = [k[7:] for k in message_keys
                       if k.startswith('openid.')]
        signed_list.append('signed')
        signed_list.sort()
        signed_message.setArg(OPENID_NS, 'signed', ','.join(signed_list))
        sig = self.getMessageSignature(signed_message)
        signed_message.setArg(OPENID_NS, 'sig', sig)
        return signed_message
788739
def unpack_messages(msgs):
        import msgpack
        

        for key, msg in msgs:
            record = msgpack.unpackb(msg)
            record['_key'] = key
            yield record
1301295
def decrypt_message(self, timestamp, nonce, msg_signature, encrypt_msg):
        
        signature = get_signature(self.token, timestamp, nonce, encrypt_msg)
        if signature != msg_signature:
            raise InvalidSignature(msg_signature)
        return self.prp_crypto.decrypt(encrypt_msg, self.app_id)
1354193
def message(self):
        
        message = self.description.format(**self.parameters)
        return '{code} {message}'.format(code=self.code, message=message)
319725
def get_message_metadata(self, key: str) -> MaildirMessage:
        
        msg = MaildirMessage()
        subpath = self._lookup(key)
        subdir, name = os.path.split(subpath)
        msg.set_subdir(subdir)
        if self.colon in name:
            msg.set_info(name.rsplit(self.colon, 1)[-1])
        msg.set_date(os.path.getmtime(os.path.join(self._path, subpath)))
        return msg
866351
def wrap(self, message):
        
        cipher_text = _Ntlm2Session.encrypt(self, message)
        signature = _Ntlm2Session.sign(self, message)
        return cipher_text, signature
1138911
def message_with_placeholders(message):
    
    new_message = message.copy()
    for attr in PLACEHOLDER_FORMAT.keys():
        if message.get(attr) is not None:
            content = message[attr]
            placeholder = PLACEHOLDER_FORMAT[attr].format(length=len(content))
            new_message[attr] = placeholder
    return new_message
272781
def parse_message(
        self, body, timestamp=None, nonce=None, msg_signature=None
    ):
        
        message_dict = parse_xml(body)
        if "Encrypt" in message_dict:
            xml = self.crypto.decrypt_message(
                timestamp=timestamp,
                nonce=nonce,
                msg_signature=msg_signature,
                encrypt_msg=message_dict["Encrypt"]
            )
            message_dict = parse_xml(xml)
        return process_message(message_dict)
1301572
def _messageFromSender(self, sender, messageID):
        
        return self.store.findUnique(
            _QueuedMessage,
            AND(_QueuedMessage.senderUsername == sender.localpart,
                _QueuedMessage.senderDomain == sender.domain,
                _QueuedMessage.messageID == messageID),
            default=None)
670114
def serialize_message(message):
        
        try:
            return bson.dumps(message.serialize())
        except bson.UnknownSerializerError:
            raise SerializationError(
                "Unable to serialize message: {}.".format(message)
            )