Skip to content

Commit a56be0f

Browse files
committed
remove memoryview from sha1 file hashing
Signed-off-by: Paul Horton <[email protected]>
1 parent 10c6b51 commit a56be0f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

cyclonedx/model/__init__.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ def sha1sum(filename: str) -> str:
3939
SHA-1 hash
4040
"""
4141
h = hashlib.sha1()
42-
b = bytearray(128 * 1024)
43-
mv = memoryview(b)
44-
with open(filename, 'rb', buffering=0) as f:
45-
for n in iter(lambda: f.readinto(mv), 0):
46-
h.update(mv[:n])
42+
with open(filename, 'rb') as f:
43+
for byte_block in iter(lambda: f.read(4096), b""):
44+
h.update(byte_block)
4745
return h.hexdigest()
4846

4947

0 commit comments

Comments
 (0)