Python Decode OctetString 7-bit Characters

182 views Asked by At

I'm currently playing around with decoded asn1 data and can't wrap my head around correctly decoding the data into strings (if the data is numerical it's working absolutely fine)

Example: Hex String -> 0ddc2f93c6c7bb10 Expected Result -> MegaFon

According to the spec the first two octets are meta info and starting with octet 3 there should be two 7 bit chars in each octet

I tried to use the soltion's mentioned in decode 7-bit GSM but I just get scrap returns, would highly appreciate any ideas

1

There are 1 answers

0
zeitghaist On

managed to solve the riddle in the meantime (@BoarGules, you are right, the spec is misleading from my perspective). First of all, for Chars (the hex starts with d0 in this case), the nibbles must not be rotated as it is done for numerical output. Then just cut out the first two octets (d0 in our case) and run it through the gsm7bitdecode function mentioned in the other stackoverlow thread (linked in the question). To keep with the example 'CD' => 11001101, cut the first bit or set it to 0 gives us 01001101 or 4D in Hex which is M in Ascii!