Joseph Farah
Joseph Farah

Reputation: 2534

What do hex values in a hex dump correspond to?

Running xxd 1.py returns this output:

jrfar /cygdrive/c/Users/jrfar/Documents/stack_overflow $
xxd 1.py
00000000: 776f 7264 735f 6e75 6d5f 6469 6374 203d  words_num_dict =
00000010: 207b 2731 273a 276f 6e65 272c 2027 3227   {'1':'one', '2'
00000020: 3a27 7477 6f27 2c20 2733 273a 2774 6872  :'two', '3':'thr
00000030: 6565 272c 2027 3427 3a27 666f 7572 272c  ee', '4':'four',
00000040: 200a 2735 273a 2766 6976 6527 7d0a 6e75   .'5':'five'}.nu
00000050: 6d20 3d20 696e 7428 696e 7075 7428 2745  m = int(input('E
00000060: 6e74 6572 2061 206e 756d 6265 7220 2832  nter a number (2
00000070: 2d35 293a 2027 2929 0a63 6f75 6e74 203d  -5): ')).count =
00000080: 2032 0a77 6869 6c65 2063 6f75 6e74 203c   2.while count <
00000090: 3d20 6e75 6d3a 0a20 2020 2069 6620 6e75  = num:.    if nu
000000a0: 6d20 3e20 353a 0a20 2020 2020 2020 2070  m > 5:.        p
000000b0: 7269 6e74 2827 696e 7661 6c69 642e 2729  rint('invalid.')
000000c0: 0a20 2020 2020 2020 206e 756d 203d 2069  .        num = i
000000d0: 6e74 2869 6e70 7574 2827 456e 7465 7220  nt(input('Enter
000000e0: 6120 6e75 6d62 6572 2028 322d 3529 3a20  a number (2-5):
000000f0: 2729 290a 2020 2020 7072 696e 7428 776f  ')).    print(wo
00000100: 7264 735f 6e75 6d5f 6469 6374 5b28 7374  rds_num_dict[(st
00000110: 7228 636f 756e 7429 295d 290a 2020 2020  r(count))]).
00000120: 636f 756e 7420 3d20 636f 756e 7420 2b20  count = count +
00000130: 310a                                     1.
jrfar /cygdrive/c/Users/jrfar/Documents/stack_overflow $

What do the hex values correspond to? I don't think they can be letters, definitely not words. I did some research and it looks like they might be individual functions, but there are like a hundred values. Reading through the xxd man page reveals that it is...a hexdump, but not much more.

What does each mean?

Thanks in advance!

Upvotes: 0

Views: 365

Answers (2)

John Kugelman
John Kugelman

Reputation: 361605

00000000: 776f 7264 735f 6e75 6d5f 6469 6374 203d  words_num_dict =
  • 77 is the hex value for the ASCII character w.
  • 6f is the hex value for the ASCII character o.
  • 72 is the hex value for the ASCII character r.
  • 64 is the hex value for the ASCII character d.
  • etc.


(source: asciitable.com)

Upvotes: 5

Eugene K
Eugene K

Reputation: 3457

You've hexdumped a text file, specifically encoded in ASCII.

The numbers you're seeing are the ASCII representations of the characters it supports.

Meaning: 776f 7264 ->

77 : w
6f : o
72 : r
64 : d

http://www.asciitable.com/

Upvotes: 2

Related Questions