completed test exc
@ -18,7 +18,7 @@ To test run 'FileComparison.py' in your command line
|
||||
Notes:
|
||||
* do not change class structure or method signature to not break unit tests
|
||||
* visit this url for more information on this topic:
|
||||
https://home.cs.colorado.edu/~jrblack/papers/cbh.html
|
||||
https://home.cs.colorado.edu/~jrblack1/papers/cbh.html
|
||||
"""
|
||||
from cryptography.hazmat.primitives import hashes
|
||||
from os import listdir
|
||||
@ -33,7 +33,11 @@ with open(path + '/original.png', 'rb') as original_file:
|
||||
# TODO 1: Find the hash of the original file
|
||||
# use SHA256() hash function
|
||||
|
||||
original_hash = None # you need to modify this
|
||||
# original_hash =
|
||||
# has original file
|
||||
original_hash = hashes.Hash(hashes.SHA256())
|
||||
original_hash.update(content)
|
||||
original_hash = original_hash.finalize()
|
||||
|
||||
|
||||
file_list = [f for f in listdir(path + '/received/') if isfile(join(path + '/received/', f))]
|
||||
@ -47,8 +51,9 @@ for f in file_list:
|
||||
with open(path + '/received/' + f, 'rb') as copy_file:
|
||||
content = copy_file.read()
|
||||
|
||||
hash = f # you need to modify this
|
||||
|
||||
hash = hashes.Hash(hashes.SHA256())
|
||||
hash.update(content)
|
||||
hash = hash.finalize()
|
||||
if hash == original_hash:
|
||||
print(f, 'is original!')
|
||||
else:
|
||||
|
Before Width: | Height: | Size: 2.9 MiB After Width: | Height: | Size: 2.9 MiB |
Before Width: | Height: | Size: 2.9 MiB After Width: | Height: | Size: 2.9 MiB |
Before Width: | Height: | Size: 2.9 MiB After Width: | Height: | Size: 2.9 MiB |
Before Width: | Height: | Size: 2.9 MiB After Width: | Height: | Size: 2.9 MiB |
Before Width: | Height: | Size: 2.9 MiB After Width: | Height: | Size: 2.9 MiB |