Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def encode_int(obj):
- ret = []
- if obj < 0:
- obj = abs(obj)
- neg = True
- else:
- neg = False
- while obj:
- ret.append(obj & 0xFF)
- obj = obj >> 8
- if neg:
- ret[0] = ret[0] | 0x80
- ret.insert(0, (0x10 + len(ret)))
- return ''.join([chr(x) for x in ret])
Add Comment
Please, Sign In to add comment