- Mastering Reverse Engineering
- Reginald Wong
- 472字
- 2021-06-10 19:40:29
Converting between bases
We have already converted hexadecimal and binary numbers into decimal, or base-10. Converting base-10 into other bases simply requires division of the base being converted into, while taking note of the remainders.
The following is an example for base-2
87 to base-2
87 divided by 2 is 43 remainder 1.
43 divided by 2 is 21 remainder 1.
21 divided by 2 is 10 remainder 1.
10 divided by 2 is 5 remainder 0.
5 divided by 2 is 2 remainder 1.
2 divided by 2 is 1 remainder 0.
1 divided by 2 is 0 remainder 1.
and nothing more to divide since we're down to 0.
base-2 has digits 0 and 1.
Writing the remainders backward results to 1010111b.
The following is an example for base-16:
34512 to base-16
34512 divided by 16 is 2157 remainder 0.
2157 divided by 16 is 134 remainder 13 (0Dh)
134 divided by 16 is 8 remainder 6.
6 divided by 16 is 0 remainder 6.
base-16 has digits from 0 to 9 and A to F.
Writing the remainders backward results to 66D0h.
Converting from hexadecimal into binary simply requires knowing how many binary digits there are in a hexadecimal digit. The highest digit for a hexadecimal number is 0Fh (15) and is equivalent to 1111b. Take note that there are 4 binary digits in a hexadecimal digit. An example conversion is shown here:
ABCDh
0Ah = 1010b
0Bh = 1011b
0Ch = 1100b
0Dh = 1101b
Just combine the equivalent binary number.
ABCDh = 1010101111001101b
Split the binary number into four digits each when converting from binary into hexadecimal, as shown here:
1010010111010111b
1010b = 10 (0Ah)
0101b = 5
1101b = 13 (0Dh)
0111b = 7
1010010111010111b = A5D7h
So, why the use of base-2 and base-16 in computers, rather than our daily base-10 usage? Well, for base-2, there are two states: an on and an off signal. A state can easily be read and transmitted electronically. Base-16 compresses the representation of the binary equivalent of a decimal number. Take 10 for instance: this number is represented as 1010b and consumes 4 bits. To maximize the information that can be stored in 4 bits, we can represent numbers from 0 to 15 instead.
A 4-bit value is also called a nibble. It is half of a byte. Bytes can represent alphabets, numbers, and characters. This representation of characters is mapped in the ASCII table. The ASCII table has three sections: control, printable, and extended characters. There are 255 (FFh) ASCII characters. Lists of printable characters that can be typed on the keyboard and some of the extended characters with keyboard format can be found at https://github.com/PacktPublishing/Mastering-Reverse-Engineering/tree/master/ch3.
Though not directly visible from the English language keyboard, symbols can still be displayed by using the character's equivalent code.
- Learning Python for Forensics
- CSO進階之路:從安全工程師到首席安全官
- 黑客攻防與無線安全從新手到高手(超值版)
- Python Penetration Testing Cookbook
- 數據安全與流通:技術、架構與實踐
- Disaster Recovery Using VMware vSphere Replication and vCenter Site Recovery Manager
- INSTANT Kali Linux
- Web安全攻防從入門到精通
- Practical Mobile Forensics
- 社會工程:防范釣魚欺詐(卷3)
- 2023—2024年中國網絡安全發展藍皮書
- 大數據安全治理與防范:反欺詐體系建設
- 網站入侵與腳本技術快速防殺
- 基于數據科學的惡意軟件分析
- 0day安全