Created
January 9, 2017 16:57
-
-
Save Tony3-sec/85986f1f129c8bb1e0b38bedd3ca1be7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## 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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment