I'm looking for information on开发者_如何学Python how to encode a small amount of binary data (say, around 200 bytes) into a PNG through colors; essentially what Hid.im does for .torrent
files. Any information or springboard for a best practice would be stellar.
Thanks!
The very basics of hiding a data in an lossless-compressed image is modifying the lower bits of every pixel, so that altogether those bits mean something.
For example in R.G.B., you can modify the last bit in Red color value (technically human eye is less sensitive to red that to green or blue).
For example, let's draw a line of 8 pixel, such as Red value of every pixel has a value of previous pixel's Red + 1
Pixel1 = (120, 203, 391)
Pixel2 = (121, ..., ...)
...
Pixel8 = (128, ..., ...)
In binary form it is:
Pixel1 = (01111000, ..., ...)
Pixel2 = (01111001, ..., ...)
...
Pixel8 = (10000000, ..., ...)
Now, let's encrypt number 63 in that line:
63 = 00011111
# Encrypting from right to left, by writing the data to the minor bit
Pixel1 = (0111100[0], ..., ...) -> 120
Pixel2 = (0111100[0], ..., ...) -> 120
Pixel3 = (0111101[0], ..., ...) -> 122
Pixel4 = (0111101[1], ..., ...) -> 123
Pixel5 = (0111110[1], ..., ...) -> 125
...
Pixel8 = (1000000[1], ..., ...) -> 129
That's it. You know where the information is and how it should be extracted. Yet, this method is very limited by capacity.
精彩评论