def
Hasher
(
algorithm
,
blocksize
)
:
def
hash_file
(
file
)
:
hash
=
algorithm
(
)
with
open
(
file
,
'rb'
)
as
f:
for
chunk
in
iter
(
lambda
: f.
read
(
4096
)
,
''
)
:
hash
.
update
(
chunk
)
return
hash
.
hexdigest
(
)
return
hash_file