def parse(self, buf): header = buf.read(12) if len(header) != 12 or header[:4] != self.magic: return self.bitsize = uint32(header[4:8]) self.e = long(uint32(header[8:12])) n = buf.read(self.bitsize / 8) if len(n) != self.bitsize / 8: return self.n = bigint(n, self.bitsize) return 12 + self.bitsize / 8
def ipv4(s): if isinstance(s, basestring): if len(s) == 4: return socket.inet_ntoa(s) if re.match(ipv4_regex, s): return s if isinstance(s, (int, long)): return socket.inet_ntoa(uint32(s)[::-1])
def ipv4(s): if isinstance(s, str): if len(s) == 4: return socket.inet_ntoa(bytes(s, "utf-8")) if re.match(ipv4_regex, s): return s if isinstance(s, (int, float)): return socket.inet_ntoa(uint32(s)[::-1])
def ipv4(s): if isinstance(s, str): if len(s) == 4: return socket.inet_ntoa(s.encode("utf-8")) print(s) if re.match(ipv4_regex, s): return s if isinstance(s, int): return socket.inet_ntoa(uint32(s)[::-1])
def uint32v(self, addr): """Read unsigned 32-bit value at address.""" return uint32(self.readv(addr, 4))
def uint32p(self, offset): """Read unsigned 32-bit value at offset.""" return uint32(self.read(offset, 4))
def parse(self, buf): length = uint32(buf.read(4)) value = buf.read() if length != len(value): return self.key = value