Remix.run Logo
nneonneo 7 days ago

Useful ones to know:

- `R0lGOD` - GIF files

- `iVBOR` - PNG files

- `/9j/` - JPG files

- `eyJ` - JSON

- `PD94` - XML

- `MII` - ASN.1 file, such as a certificate or private key

These are nice to know since they show up pretty frequently (images in data: URLs, JSON/XML/ASN.1 in various protocols).

0points 6 days ago | parent | next [-]

> GIF, PNG, JPG

It makes more sense to transmit binary formats in binary.

You would save bandwidth, memory and a decoding step.

Then you could also inspect the header bytes, instead of memorizing how they present in some intermediate encoding.

mr_mitm 6 days ago | parent | next [-]

Knowing these magic bytes in base64 is mostly relevant in situations in which you see data encoded by other people, which means you probably had no control over the encoding. Other people (or rather every body) sometimes do things which don't make sense.

demurgos 6 days ago | parent | prev | next [-]

Sometimes you need to embed binary data in a text format (e.g. JSON).

naikrovek 6 days ago | parent [-]

the amount of data i have stuffed into json as base64 encoded text makes me sick.

i wrote a glTF model converter once. 99% of those millions of JSON files I wrote were base64 encoded binary data.

a single glTF model sometimes wants to be two files on disk. one for the JSON and one for the binary data, and you use the JSON to describe where in the binary data the vertices are defined, and other windows for the various other bits like the triangles, triangle fans, textures, and other stuff are stored. But you can also base64 encode that data and put it in the JSON file and not have a messy double-file model. so that's what I did and I hated it. but it still felt better than having .gltf files and .bin files which together made up a single model file.

ThrowawayTestr 6 days ago | parent | prev | next [-]

I have a tampermonkey script that's a megabyte in size because it includes an encoded gif file.

moralestapia 6 days ago | parent | prev [-]

Thanks, GPT.

feliixh 7 days ago | parent | prev [-]

Very useful!