Python hex conversion
-
How to convert service = b'\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfb\xaa\xed\xde'
to
DEEDAAFB-000-0000-0000-000000000002
-
@misterlisty
s = "".join(["%02X" % b[i] for i in range(len(service) - 1,-1,-1)])
resulting in:
DEEDAAFB000000000000000000000001
sm = s[:8] + "-" + s[8:12] + "-" + s[12:16]+"-"+ s[16:20] + "-" + s[20:]
resulting in:
DEEDAAFB-0000-0000-0000-000000000001Which is however on letter longer than the string above. So check whether in the second group it is really three 0's.
Edit: for the second step, you can also write:
sm = "-".join([s[:8], s[8:12], s[12:16], s[16:20], s[20:]])
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login