Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In this task, we are to explore a simple image encryption. An example of an image encryption is written in Python as follows: # Simple
In this task, we are to explore a simple image encryption. An example of an image encryption is written in Python as follows: # Simple Python Code ifile, ofile sysarg: with openifilerb as reader: with openofilewb as writer: imagedata reader.read header, body imagedata: imagedata: body bxlenbody writer.writeheader aesEncryptor.updatebody Your first task is to understand the idea of the above code. This is a very basic AES encrypting program, and the key that is used for encrypting it does not really matter much. It means, you can just choose any random key for this, or just use a fixed test key. We will need to first read a binary file, encrypt everything except the first bytes, and then write it out to a new file. The reason we are not encrypting the first bytes is because this program is going to encrypt the contents of a bitmap file BMP and the header is bytes in length. You should try to use an image editor of your choice to create a large image with text that takes up most of the space. Then save the encrypted file to something encryptedimage.bmp then open the file with an image viewer. Finally, write a decryption program to decrypt the encrypted image. If you can see the original image, then it means you have done this first step correctly. The main idea of this task is to understand the difference between AESCBC and AESCTR mode. Do the following steps. First introduce an error into the ciphertext and decrypt the modified bytes. Try for example picking the byte right in the middle of the encrypted image data and setting it to After corrupting the data, call the decryption program and view the restored image. Compare the impact between CBC and CTR mode. Based on this experiment, write a report to demonstrate the difference and impact between CBC and CTR mode. Hints: You can try with an allwhite image. If you still cannot figure it out, change bytes or so to figure out where the changes are happening. Once you find where the changes are happening, go back to changing a single byte to view the differences between CTR and CBC Can you explain what is happening there clearly in the report? You can choose to use C or Java to implement this part too. It is not necessary to use Python.
In this task, we are to explore a simple image encryption. An example of an image encryption is
written in Python as follows:
# Simple Python Code
ifile, ofile sysarg:
with openifilerb as reader:
with openofilewb as writer:
imagedata reader.read
header, body imagedata: imagedata:
body bxlenbody
writer.writeheader aesEncryptor.updatebody
Your first task is to understand the idea of the above code. This is a very basic AES encrypting
program, and the key that is used for encrypting it does not really matter much. It means, you
can just choose any random key for this, or just use a fixed test key. We will need to first read
a binary file, encrypt everything except the first bytes, and then write it out to a new file. The
reason we are not encrypting the first bytes is because this program is going to encrypt the
contents of a bitmap file BMP and the header is bytes in length. You should try to use an
image editor of your choice to create a large image with text that takes up most of the space.
Then save the encrypted file to something encryptedimage.bmp then open the file with an image
viewer. Finally, write a decryption program to decrypt the encrypted image. If you can see the
original image, then it means you have done this first step correctly.
The main idea of this task is to understand the difference between AESCBC and AESCTR
mode. Do the following steps.
First introduce an error into the ciphertext and decrypt the modified bytes. Try for example
picking the byte right in the middle of the encrypted image data and setting it to After corrupting the data, call the decryption program and view the restored image. Compare the impact
between CBC and CTR mode. Based on this experiment, write a report to demonstrate the difference and impact between CBC and CTR mode.
Hints: You can try with an allwhite image. If you still cannot figure it out, change bytes or
so to figure out where the changes are happening. Once you find where the changes are happening, go back to changing a single byte to view the differences between CTR and CBC Can you
explain what is happening there clearly in the report?
You can choose to use C or Java to implement this part too. It is not necessary to use Python.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started