def send_raw(self, data): msg_len = len(data) >> 2 tcp_stream = self._get_tcp_stream() if self._send_abridged_flag: tcp_stream.write(chr(0xef)) self._send_abridged_flag = False if msg_len < 127: tcp_stream.write(Bytes.from_int(msg_len, 1, False)) else: tcp_stream.write(chr(0x7f)) tcp_stream.write(Bytes.from_int(msg_len, 3, False)) tcp_stream.write(data)
def serialize_int32(i, signed=True): return Bytes.from_int(i, 4, False, signed)
def rsa_encrypt(plain, key): if isinstance(plain, Bytes): plain = plain.to_int(True) return Bytes.from_int(pow(plain, key.e, key.n), 256, True)
def serialize(self): ser_id = Bytes.from_int(self.ID, 4, False, False) ser_params = super(TLFunction, self).serialize() return ser_id + ser_params
def serialize_long(l, signed=True): return Bytes.from_int(l, 8, False, signed)
def serialize(self): v = self.get() return Bytes.from_int(v, 16, True)
def serialize(self): itos = Bytes.from_int(self.get(), self._byte_len, True, self._signed) tls = TL_string(itos) return tls.serialize()
def serialize(self): return Bytes.from_int(self.get(), 32, True, signed=self._signed)