python len calculation
Posted
by
n00bz0r
on Stack Overflow
See other posts from Stack Overflow
or by n00bz0r
Published on 2012-03-22T17:19:31Z
Indexed on
2012/03/22
17:31 UTC
Read the original article
Hit count: 203
python
I'm currently trying to build a RDP client in python and I came across the following issue with a len check;
From: http://msdn.microsoft.com/en-us/library/cc240836%28v=prot.10%29.aspx
"81 2a -> ConnectData::connectPDU length = 298 bytes Since the most significant bit of the first byte (0x81) is set to 1 and the following bit is set to 0, the length is given by the low six bits of the first byte and the second byte. Hence, the value is 0x12a, which is 298 bytes."
This sounds weird.
For normal len checks, I'm simply using : struct.pack(">h",len(str(PacketLen)))
but in this case, I really don't see how I can calculate the len as described above.
Any help on this would be greatly appreciated !
© Stack Overflow or respective owner