Skip to content

Commit

Permalink
remove memoryview from sha1 file hashing
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Horton <phorton@sonatype.com>
  • Loading branch information
madpah committed Oct 21, 2021
1 parent 10c6b51 commit a56be0f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions cyclonedx/model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ def sha1sum(filename: str) -> str:
SHA-1 hash
"""
h = hashlib.sha1()
b = bytearray(128 * 1024)
mv = memoryview(b)
with open(filename, 'rb', buffering=0) as f:
for n in iter(lambda: f.readinto(mv), 0):
h.update(mv[:n])
with open(filename, 'rb') as f:
for byte_block in iter(lambda: f.read(4096), b""):
h.update(byte_block)
return h.hexdigest()


Expand Down

0 comments on commit a56be0f

Please sign in to comment.