Problem Given the target file f0 and candidate files f1-f20, there is an identical copy of f0 among the files f1-f20. Write a python program to perform the following tasks: · Read in each file and calculate the hex hash values by using SHA3 function with the length of 512 for all the given files f0, f1-f20. · Save the hex hash values of each file as a new line in a .txt file named hash.txt file. · Read hash values from hash.txt and compare them to find the identical copy of f0 among f1-f20. · Write the finding result (the matched file name) back to hash.txt Submission • Name your project fileHash.py and submit both fileHash.py and hash.txt on Blackboard. • The program should be properly documented. • The program should have user friendly Input/Output design • Duplicate work (or obviously similar one) will result in an F grade in the course. Grading 1. Include comments as specified in the course syllabus. (10%) 2. Source code and results. · Correctness (70%) · User-friendliness in I/O design (10%) · Efficiency of the code (10%) Sample Code The following code is an example of reading a file and calculate the hash value of the file by using SHA2 function with the length of 256 import hashlib file_path = input("Enter the file path: ") BLOCK_SIZE = 65536 hash_handler = hashlib.sha256() with open(file_path, 'rb') as f: fb = f.read(BLOCK_SIZE) while fb: hash_handler.update(fb) fb = f.read(BLOCK_SIZE) file_hexhash = hash_handler.hexdigest() print(f"{file_path} file hash value: \n{file_hexhash}"
Problem
Given the target file f0 and candidate files f1-f20, there is an identical copy of f0 among the files f1-f20.
Write a python program to perform the following tasks:
· Read in each file and calculate the hex hash values by using SHA3 function with the length of 512 for all the given files f0, f1-f20.
· Save the hex hash values of each file as a new line in a .txt file named hash.txt file.
· Read hash values from hash.txt and compare them to find the identical copy of f0 among f1-f20.
· Write the finding result (the matched file name) back to hash.txt
Submission
• Name your project fileHash.py and submit both fileHash.py and hash.txt on Blackboard.
• The program should be properly documented.
• The program should have user friendly Input/Output design
• Duplicate work (or obviously similar one) will result in an F grade in the course.
Grading
1. Include comments as specified in the course syllabus. (10%)
2. Source code and results.
· Correctness (70%)
· User-friendliness in I/O design (10%)
· Efficiency of the code (10%)
Sample Code
The following code is an example of reading a file and calculate the hash value of the file by using SHA2 function with the length of 256
import hashlib file_path = input("Enter the file path: ")
BLOCK_SIZE = 65536 hash_handler = hashlib.sha256() with open(file_path, 'rb') as f: fb = f.read(BLOCK_SIZE) while fb: hash_handler.update(fb) fb = f.read(BLOCK_SIZE) file_hexhash = hash_handler.hexdigest() print(f"{file_path} file hash value: \n{file_hexhash}"
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)