I'm trying to encode an image using the Feistel cipher. The idea was to take an image file, read byte per byte the image, encode every byte with my Feistel cipher, and re-create a new image with the encoded byte generated by the cipher.
Unfortunately, I've found out most of the common image formats use headers that, once encoded, make the encoded image corrupted.
Having a look at the PIL package I've found out the PIL.Image.frombytes
function is able to create an image object given a BytesIO
object. With the image object, I'm able to recreate the image with the save
function
My issue now is, how to open an image and read the actual image payload in bytes that I need to process with my Feistel cipher.
If I use the code
with open('image.jpg', 'rb') as file:
data = file.read()
I read the whole file, including the headers, which I don't need