Skip to content

What is a magic byte anyway? This tutorial will get you comfortable with the concept.

Notifications You must be signed in to change notification settings

Cerchie/magic-byte-illustration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

magic-byte-illustration

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:

first few lines are PK���������;



## 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:

first few lines read %PDF-���������



## 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?

About

What is a magic byte anyway? This tutorial will get you comfortable with the concept.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published