Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is binary data?

gcc 4.6.0

What does binary data look like? Is it all 1's and 0's.

I was just wondering, as I was talking to another programmer about copying strings and binary data.

Normally, I use strcpy/strncpy functions to copy strings and memcpy/memmove to copy binary data. However, I am just wondering what does it looks like?

Many thanks for any suggestions,

like image 520
ant2009 Avatar asked Jun 11 '11 05:06

ant2009


2 Answers

depends on what you're using to view it. here it's in hexadecimal and ASCII:

jcomeau@intrepid:~$ xxd /bin/bash | head -n 10
0000000: 7f45 4c46 0101 0100 0000 0000 0000 0000  .ELF............
0000010: 0200 0300 0100 0000 5021 0608 3400 0000  ........P!..4...
0000020: 345c 0c00 0000 0000 3400 2000 0800 2800  4\......4. ...(.
0000030: 1c00 1b00 0600 0000 3400 0000 3480 0408  ........4...4...
0000040: 3480 0408 0001 0000 0001 0000 0500 0000  4...............
0000050: 0400 0000 0300 0000 3401 0000 3481 0408  ........4...4...
0000060: 3481 0408 1300 0000 1300 0000 0400 0000  4...............
0000070: 0100 0000 0100 0000 0000 0000 0080 0408  ................
0000080: 0080 0408 c013 0c00 c013 0c00 0500 0000  ................
0000090: 0010 0000 0100 0000 c013 0c00 c0a3 1008  ................

here's another way to view it:

jcomeau@intrepid:~$ convert -size 640x$(($(stat -c %s /bin/bash)/640)) \
 -depth 8 gray:/bin/bash /tmp/bash.png
jcomeau@intrepid:~$ firefox /tmp/bash.png

enter image description here

like image 157
jcomeau_ictx Avatar answered Nov 15 '22 10:11

jcomeau_ictx


Binary data is just a way of saying that it's data which is not text. In other words, it doesn't actually give you a lot of insight as to what the data is, rather it gives you insight as to what the data isn't.

The odd bit is that, in the most technical sense of the words, text is also binary data.

like image 24
Edwin Buck Avatar answered Nov 15 '22 09:11

Edwin Buck