Whats Hex Dump - What does it mean?

2020-06-04 06:42发布

thegladiator:~/cp$ cat new.txt
Hello World This is a Trest Progyy

thegladiator:~/cp$ hexdump new.txt
0000000 6548 6c6c 206f 6f57 6c72 2064 6854 7369
0000010 6920 2073 2061 7254 7365 2074 7250 676f
0000020 7979 000a                              
0000023

How is that text data represented in Hex like that ? What is the meaning of this ? Please can anyone tell me .

标签: hexdump
2条回答
劳资没心,怎么记你
2楼-- · 2020-06-04 06:54

it's just what it says, a dump of the data in hexidecimal format:

H 48 
e 65
l 6c
l 6c
o 6f

It is odd though that all of the bytes are swapped (65 48 : e H)

If you're on a *nix system, you can use 'od -x', or 'man od' will tell you all the ways to get data from od :)

查看更多
smile是对你的礼貌
3楼-- · 2020-06-04 07:11

The text in the file new.txt is stored using ASCII encoding. Each letter is represented by a number, decimal: 32-127 hexidecimal: 20-7F. So the first three letters (H,e,l), are represented by the decimal numbers: 72,101,108 and the hexidecimal numbers: 48,65,6C

Hexdump by default takes each 16 bit word of the input file new.txt and outputs this word as a Hexidecimal number. Because it is operating on 16 bits, not 8 bits, you see the output in an unexpected order.

If you instead use xxd new.txt, you will see the output in the expected order.

查看更多
登录 后发表回答