Live data from Hacker News

Coding Challenge for MI5

mi5.gov.uk

41–43 of 43 posts

Re: Coding Challenge for MI5

#41
Code-golf anyone? Here's my bash one-liner:

    pngtopnm puzzle.png | xxd -s14 -p -c3 | uniq -c | awk '{printf "%c", $1}' | xxd -r -p
Explanation:

   pngtopnm converts the image to an uncompressed bytestream format (pnm)
   xxd converts the bytes to hex representation
      -s14 skips the pnm header
      -p gives plain hex output
      -c groups by 3 byte values (RGB pixel values)
   uniq -c counts the run length encoding of the hex triplets
   awk / printf %c converts the RLE count to an ascii value
   xxd -r reverses the hex dump to the final encoded message

Re: Coding Challenge for MI5

#42

OK, so, the obvious "congratulations" messages aside, what's really in that file? Example: Take the PNG, convert it to another lossless format. Then convert that lossless format back to PNG. Different file size, right? OK, the comment accounts for about 120 bytes.. but what about the rest? Why is it that much bigger? "As I read, numbers I see. 'Twould be a great shame not to count this art among the great texts of ou…

The alpha channel? Edit: You're right though. Using imagemagick to clone it like so: convert puzzle.png puzzle2.png results in an image that's at least 40% smaller. It might just be better compression, but there might be another layer of steganography going on.

I unpacked the chunks and there doesn't look to be much more (or it's subtle).

The IDAT chunk (which makes up most of the file) is DEFLATE-d but uses full color (rather than palettized color, which would have saved lots of space, and might be how you'd get 40% compression). It also doesn't use any row filtering.

I checked incase something was hidden in the DEFLATE encoding itself (e.g. using sub-optimal block encoding selection) but this round-trips exactly, so I don't think it can be.

Post reply on HN