Answered step by step
Verified Expert Solution
Link Copied!

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 = sys.arg[1:3]
with open(ifile,"rb") as reader:
with open(ofile,"wb+") as writer:
image_data = reader.read()
header, body = image_data[:54], image_data[54:]
body += b"\x00"*(16-(len(body)%16))
writer.write(header + aesEncryptor.update(body))
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 54 bytes, and then write it out to a new file. The
reason we are not encrypting the first 54 bytes is because this program is going to encrypt the
contents of a bitmap file (BMP) and the header is 54 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 encrypted_image.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 AES-CBC and AES-CTR
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 0. 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 all-white image. If you still cannot figure it out, change 50 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

Write short notes on Interviews.

Answered: 1 week ago

Question

1 Why is job analysis important?

Answered: 1 week ago