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}"

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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}"

Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Files and Directory
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education