Reference no: EM133527720
Applied Cryptography Assignment
Assignment 1:
In this Assignment, you will be applying symmetric encryption, decryption, and hashing of data files using the Python programming language.
Learning Outcome 1: Explain the concepts and principles on which modern cryptography relies upon.
Learning Outcome 2: Employ adapted cryptographic tools and techniques to encrypt, decrypt and sign messages.
Learning Outcome 3: Decipher simple encrypted messages using a range of cryptanalysis methods.
The Assignment
Your mission, should you choose to accept it, is to take a given data file and a partially complete python file and finish the encryption / decryption / hashing / and collision checking activities outlined below.
While this is not a programming unit, you may, in the future need to explore how to use a new st
library to achieve a task. This assignment will get
you to look at the documentation for a small number of Python cryptographic libraries and apply those libraries to your problem. the main cryptography python library - can be used to provide some functionality to encrypt, decrypt, and hash files with symmetric cryptography and hash functions.
What we've provided for you:
1. birthday_aNack_statistics.py - A file that runs a simulated 'birthday aflack' scenario on a random sample of dates in a given date range and repols on the average number of attempts to get a collision.
2. crypto_a1_activity.py - A skeleton python file is provided in iLearn just under this specification . It contains functions to-be completed for this assignment.
3. assignment_answers.txt - A template text file for you to replace selected lines with your answers / outputs from programs.
4. two files, but you only need to use one of
them depending on your OS.
1. windows_data_encrypted.txt
2. mac_Iinux_data_encrypted.txt
Instruction
Setup: Put all of the files ( birthday_attack_statistics.py, crypto_a1_activity.py, assignment_answers.txt, windows_data_encrypted.txt,
mac_linux_data_encrypted.txt) into a folder and open that folder up in your chosen pyhon IDE (e.g. visual studio code).
Task 0:
a) run birthday_attack_statistics.py and copy the last line of the console output into the assignment_answers.txt file for subtask a. The console line should start with
"average number of attempts "
b) now, modify birthday_attack_statistics.py to start a search from your birthday date up until the assignment due date (24 September 2023). Use the lecture slides on the birthday paradox to calculate what your expected size should be for a 50% chance of a collision to have occured with this new date range. Run your updated birthday_attack_statistics.py and copy the new updated console output ¿ust the last line) for subtask b. In the line underneath, indicate if the average was close (within +-2 of what you calculated) or not close (outside 1he +-2 of what you calcualted).
Task 1:
You have been be given an encrypted file that a student has encrypted, but they forgot which student ID they typed. You suspect they might have used the student ID 4000000 instead of their student number.
• modify the task_1(...) function in crypto_a1_activity.py
• modify the decrypt_fiIe(...) function in crypto_a1_activity.py
to call the functions you need to try and decrypt a file. We've provided some empty functions in the file for you to complete with some guidance. You will also need to implement the decrypt_file(...) function for your task J to be completed.
Once you've completed the code, run your python code to decrypt the file and see what the output was: (how to run it...)
Windows users in vscode terminal: python crypto a1 activity.py 40000000 task1
windows data encrypted txt windows data decrypted txt
Mac / Linux users in vscode:
python crypto a1 activity.py
40000000 tasL1
mac Linux aa£a encrypLeo.LxL
mac linux data decrypted.txt
If you've successfully decrypted the file, then copy line 5 of the text file and paste it as your answer. Hopefully the text should be readable in English...
Task 2:
Now that you've successfully decrypted the file, what we would like to you to do is re-encrypt the file. You will need to add code into the task_2 function and also implement the encrypt_fiIe function
• modify the task_2(...) function in crypto_a1_activity.py
• modify the encrypt_fiIe(...) function in crypto_a1_activity.py
J) If you've successfully implemented the function, then you should be able to run the python file with student number 4O000OO0, take in your decrypted file, and then output to a newly encrypted txt.
2) Take the same decrypted file and encrypt it using your own student number. save the output file as task2.txt
3) & We will check the .start of your has with our version run with your student number.
Task 3:
use your student number to encrypt and decrypt the decrypted file. Write "Success:" or "not success" in your answer file for task 3. provide the first 2O characters of the encrypted file (which should be the same as task 2).
Task 4:
Hash the unencrypted data file using SHA256 and copy the hash into task 4
• modify the task_4(...) function in crypto_a1_activity.py
• modify the generate_hash(...) function in crypto_a1_activity.py
Task 5: hash the fiIe that was encrypted with your student number (task2.txt) and save the resultsin task5.txt copy the hash stored in the output file into the assignment_answers.txt file in task 5.
Attachment:- Applied Cryptography.rar