Hex encodeの自分用メモ

## Hex encode for 'Hello' is 48656c6c6f. How does this work?
>>> binascii.hexlify(b'Hello')
b'48656c6c6f' (48 65 6c 6c 6f)
## Let's encode the letter 'H'
## First, convert 'H' to ascii code
>>> ord('H')
72
## Next, convert '72' to binary digit
>>> bin(72)
'0b1001000' (01001000)
## Divide '01001000' to two part.
0100 + 1000
## Convert each binary digit to decimal
>>> int('0100', 2)
4
>>> int('1000', 2)
8
4 and 8 = 48
So the hex encode for 'H' is 48.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.