If you're curious about how magic bytes work, this tutorial can help!
(If you're using Kafka and have received a magic byte error, check out this blog post for help.)
We'll change file signatures and observe how it changes the output of the MacOS file command. (Limitation: this tutorial is for MacOS users.)
Steps:
1. git clone https://github.com/Cerchie/magic-byte-illustration.git && cd magic-byte-illustration
## 2. Now view PK.zip in your text editor. It will look something like:
## 3. PK is the file signature for the zip file format. You can verify that by running `file PK.zip`.
## 4. Let's change the file signature so that `file` reads this file as a PDF!
`git checkout change-signature-to-pdf`
When you view the file in your text editor, you can see that the signature has changed:
## 5. Run `file PK.zip` to confirm. Note that while the _extension_ is still ".zip", the file signature is for a PDF, so it's read as a PDF. Pretty cool huh?