Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to view encrypted picture

how do people view encrypted pictures like on this wiki page? is there a special program to do it, or did someone decide to do some silly xor just make a point about ECB? im not a graphics person, so if there are programs to view encrypted pictures, what are they?

like image 828
calccrypto Avatar asked May 24 '10 00:05

calccrypto


3 Answers

Encryption works on a stream of bytes. That is, it takes an array of bytes and outputs another array of bytes. Images are also just an array of bytes. We assign the "r" component of the top-left pixel to the first byte, the "g" component to the second byte, the "b" component to the third byte. The "r" component of the pixel next to that is the fourth byte and so on.

So to "encrypt" an image, you just take a byte array of the pixels in the first image, encrypt it (encryption usually doesn't change the number of bytes - apart from padding) and use those encrypted bytes as the pixel data for the second image.

Note that this is different from encrypting an entire image file. Usually an image file has a specific header (e.g. the JPEG header, etc). If you encrypted the whole file then the header would also be included and you wouldn't be able to "display" the image without decrypting the whole thing.

like image 55
Dean Harding Avatar answered Nov 17 '22 22:11

Dean Harding


To view an encrypted image, the image has to be an uncompressed image format for example bmp. PNG, JPEG and so on are compressed images so you wont't be able to display those. Also the imgae header has to be uncompressed. If you want to encrypt pictures like this, just convert it to an uncompressed format, open it with an hex editor and save the image header. After that u can encrypt the image with AES/ECB. At last you have to insert the original image header. Now you should be able to view the encrypted image.

like image 39
saiko Avatar answered Nov 18 '22 00:11

saiko


It's not just a silly XOR (they can all use XOR) but yes, it's just there to emphasize that any scheme which converts the same input to the same output every time makes it easy to spot patterns that were present in the input. The image is there to show how easily we can spot Tux in the "encrypted" output. The author could have used any kind of data, but used an image because the human eye is very good at spotting patterns, so it makes a good example.

As the article says, better schemes use the output of the previous block to "randomize" the next block, so you can't see patterns in the output (a la the image on the right).

like image 3
A.C Avatar answered Nov 17 '22 22:11

A.C