Stuffing bytes into source code

You're writing a test case, or you want to embed an Easter Egg into your app that your PM won't notice. Or whatever. I'm not judging you. You could write a 5-minute Python script, or you could do what I did and waste half an hour trying to understand the hexdump manual. Here's what I came up with:

$ hexdump -v -e '"(byte)0x" 1/1 "%02X" ", "' image.png

This will spit out something close enough to Java or C++ source code that you can mostly copy and paste it.

Categories

Leave a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

About this Entry

This page contains a single entry by Mike Tsao published on June 11, 2010 11:06 AM.

Moutai was the previous entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.2-en