-6

A browser shows the message-body in cache, something like this:

00000000:  20 20 20 20 3c 21 44 4f 43 54 59 50 45 20 68 74      <!DOCTYPE ht
00000010:  6d 6c 3e 0a 20 20 20 20 3c 68 74 6d 6c 3e 0a 20  ml>.    <html>. 
00000020:  20 20 20 3c 68 65 61 64 3e 0a 20 20 20 20 20 20     <head>.      
00000030:  20 20 3c 6d 65 74 61 20 63 68 61 72 73 65 74 3d    <meta charset=
00000040:  22 75 74 66 2d 38 22 20 2f 3e 0a 20 20 20 20 20  "utf-8" />.     
00000050:  20 20 20 3c 74 69 74 6c 65 3e 54 65 73 74 3c 2f     <title>Test</
00000060:  74 69 74 6c 65 3e 0a 20 20 20 20 3c 2f 68 65 61  title>.    </hea
00000070:  64 3e 0a 20 20 20 20 3c 62 6f 64 79 3e 0a 20 20  d>.    <body>.  
00000080:  20 20 20 20 20 20 54 65 73 74 20 63 61 63 68 69        Test cachi
00000090:  6e 67 20 62 65 68 61 76 69 6f 72 20 2e 2e 2e 0a  ng behavior ....
000000a0:  20 20 20 20 3c 2f 62 6f 64 79 3e 0a 20 20 20 20      </body>.    
000000b0:  3c 2f 68 74 6d 6c 3e                                      </html>

Why a browser is showing the message-body in 2 versions? (Hex version and non-hex version.)

For example with an image: the browser is showing the hex version and the non-hex version. If there would be cases, where you can only show the hex version and it's not possible to show the non-hex version (because of encodings or source or whatever), then i would understand it. But are there cases like that and how can i reproduce them?

  • 4
    What makes you think the body is stored as a _"hexadecimal byte string"_? What even __is__ a _"hexadecimal byte string"_? There is no such thing. – Cerbrus Nov 21 '17 at 21:05
  • 2
    That is one heavy misconception. Take a `hexdump` tool, and you can get the same kind of output out of any file. That is just a textual representation. – E_net4 Nov 21 '17 at 21:07
  • @Cerbrus You can check chrome://cache/ in Chrome or about:cache in Firefox. There the browser is showing the cache data and there they are showing a hexadecimal version, so the question is why they are doing that. – Maarten Bruins Nov 21 '17 at 21:12
  • 2
    @MaartenBruins: Correct, they are __showing__ it in that format. That doesn't mean it's __stored__ in that format. – Cerbrus Nov 21 '17 at 21:13
  • @E_net4 But if it's just a textual representation then the question is, why they are doing that? They can also just only show the non hex version? – Maarten Bruins Nov 21 '17 at 21:14
  • @MaartenBruins: How would they display images? Videos? Binary files (executables, archives, installation files)? – Cerbrus Nov 21 '17 at 21:14
  • 1
    You asked why the browser is storing the data in a hexadecimal string, which is not true. If you want to ask why it **shows** the data that way, then please edit your question. – E_net4 Nov 21 '17 at 21:16
  • @Cerbrus I only have that kind of information from other places on the internet, so that's why i wanted to know more about it, because i already thought maybe it's incorrect. See: https://gchq.github.io/CyberChef/ There i have "hexadecimal byte string" from, but apparently i can not trust the people behind CyberChef. I'll search for the source where they were talking about "storing" (so what is incorrect). – Maarten Bruins Nov 21 '17 at 21:20
  • 3
    I'm afraid that it's not so simple. See [why we don't force users to comment on their downvotes](https://meta.stackoverflow.com/q/357436/1233251). – E_net4 Nov 21 '17 at 21:46
  • @Cerbrus By the way, i changed "store" to "show" in the question and afterwards i'm still getting a lot of downvotes for the question. People has to stay objective with each question separately. I just don't understand it, the question is still wrong? – Maarten Bruins Nov 21 '17 at 23:55
  • @E_net4 Thanks for the link and explanation! Really useful! I wanted to tag you also in previous comment, but apparently and unfortunately i can only tag one use at once, so that's why i made 2 separate comments for it. – Maarten Bruins Nov 21 '17 at 23:57
  • @meagar Apparently the question was not clear enough for you (I can understand). You put it ON HOLD with that reason. I tried to change the question, so it's maybe more clear. Is it now more clear for you? And if yes, can you open it again. And if no, what can I improve? – Maarten Bruins Nov 24 '17 at 02:03

1 Answers1

4

The data isn't stored as a "hexadecimal byte string". There is no such thing.

The data is displayed in such a format because it's an accessible, and somewhat readable method of displaying all kinds of data.

Text files will just be readable.
All other formats can have their headers inspected with relative ease.

Cerbrus
  • 70,800
  • 18
  • 132
  • 147
  • If my answer is wrong in some way, please tell me. I'd be happy to correct the answer. – Cerbrus Nov 21 '17 at 21:19
  • Can't see an issue here, other than the fact that "There is no such thing" could be misinterpreted to "there is no such thing as strings with bytes in hexadecimal", but even this is a bit farfetched. I could not downvote for that. – E_net4 Nov 21 '17 at 21:23
  • Yea, okay, there is such a thing as strings containing a hexadecimal representation of bytes. One could call such a string a _"hexadecimal byte string"_. Still, it's not a actual "data format". – Cerbrus Nov 21 '17 at 21:25
  • I thought about it, but this is no answer to my question. You said in the other comments: "How would they display images?" I just tested it and they are showing 2 columns. One "hexadecimal byte string" and one not. So the question is ... why they're showing the cache content on 2 different ways? And not just the non hexadecimal version? You came with the following argument for that: "How would they display images?" My answer: just the none hexadecimal version. You can just check that version in the right column of the browser cache (of image). – Maarten Bruins Nov 21 '17 at 23:32
  • @Cerbrus You're commenting everywhere to me, but here I still don't have a reaction of you. I still have the same question (see my previous comment). – Maarten Bruins Nov 24 '17 at 01:13
  • 1
    Maybe because there is nothing more to add? That cache viewer isn't going to change it's display format depending on the file type. The format you're seeing is _extremely_ common for file inspectors. It's basically convention. – Cerbrus Nov 24 '17 at 06:24
  • @Cerbrus I've missed your last comment, so a bit late reply back. But the question still is, why it''s like that? You're saying it's extremely common. I know that. But the question is, why it is like that? Why would a browser show things in 2 different ways, while it can also show it in 1 way? Convention could be an answer, but then where can i find more information about that specific convention? And why they make a convention of something, while it's not really necessary (they could also show 1 way). That's actually what the question is about, so for me this is not a satisfactory answer yet. – Maarten Bruins Nov 28 '17 at 11:56
  • _”Why is this convention/standard”_ is off-topic for SO. – Cerbrus Nov 28 '17 at 12:09