This script hides files inside images (currenlty PNG) and outputs the modified one picture on your disk.
The maximum file size that can be hidden inside an image depends on the size of the image.
max_file_size = (height_of_image * width_of_image * 6/8) bytes
Το "100k words.txt" είναι κρυμμένο στο "original_image.png" που ονομάζεται "image_with_100k words.png". Πηγαίνετε και ελέγξτε εάν μπορείτε να εντοπίσετε τη διαφορά μεταξύ αυτών των δύο εικόνων. Μπορείτε να χρησιμοποιήσετε αυτήν την ενότητα για να εξαγάγετε "100k words.txt" από το "image_with_100k words.png".
Example of original image:
Modified image
This image has 100k words hidden inside!
How does it work;
It is based on a simple principle that if we change the LSB (Least Significant Bits) of each Pixel, then the change it will not be significant and will not be observed with the naked eye.
So this section takes 2 bits data from the file to hide and replaces the last 2 bits of a pixel with those 2 bits and then moves to the next pixel.
The maximum change in pixels can be 4 units and the value range in PNG image (0,255), so this change is not significant.
In a PNG image, each pixel has 3 channels red, green and blue. (Some PNG images have 1 or 4 channels, but this program will convert them to 3 channels) A typical pixel in a PNG image looks like:
a_pixel = (17,32,11) # (RED, GREEN, BLUE)
So we can save 3 times 2 bits per Pixel, which means 6 bits per pixel. This takes us to the upper limit of the file size, which can be hidden in an image:
max_file_size = (height_of_image * width_of_image * 6/8) bytes
Let's understand it with an example. The data that will be hidden are:
binary_data = 0b100111
Let's take the first two bits and replace them with RED Channel of our 'a_pixel'.
a_pixel = (0b10001, 0b100000, 0b1011) # binary representation of a_pixel values # Let's change a_pixel's RED Channel # 0b10001 -> 0b10010 (First 2 bits are 10) a_pixel = (0b10010, 0b100000, 0b1011) # modified pixel
Let's take 2 bits from binary_data again to replace the last 2 bits of GREEN Channel with them.
a_pixel = (0b10010, 0b100000, 0b1011) # Let's change a_pixel's GREEN Channel # 0b100000 -> 0b100001 (The 2 bits are 01) a_pixel = (0b10010, 0b100001, 0b1011) # modified pixel
Let's do it again with the BLUE Channel and we're done.
a_pixel = (0b10010, 0b100001, 0b1011) # Let's change a_pixel's BLUE Channel # 0b1011 -> 0b1011 (The 2 bits are 11); Notice that the value wasn't changed this time a_pixel = (0b10010, 0b100001, 0b1011) # pixel wasn't modified this time
So we have hidden a 6 bit message in one pixel. Let's look at the changes in the pixel
a_pixel = (0b10001, 0b100000, 0b1011) = (17, 32, 11) a_pixel_with_data = (0b10010, 0b100001, 0b1011) = (18, 33, 11)
As we can see that the change is not even noticeable at the pixel level. The Module does this repeatedly until all our data is stored in the image.
NOTE: Ο "θόρυβος" στη φωτογραφία αυξάνεται και εάν χρησιμοποιήσουμε οποιοδήποτε λογισμικό επεξεργασίας φωτογραφιών για να την συγκρίνουμε με την αρχική εικόνα, τότε αυτή η εικόνα θα έχει πολύ περισσότερο θόρυβο από την αρχική εικόνα.
Very smart way to put messages in pictures !!!