Skip to content

Commit e5de8dd

Browse files
committed
Check buffer position instead of length when calculating bsha digest
Since the buffer is now of fixed size, checking its length for >0 would always yield True. Might be related to #2
1 parent aa45642 commit e5de8dd

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

bncs/hashing/bsha.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ def lockdown_sha1(*data):
3030
XSha1: a0db6e70616033a7b5fdda37cee2d43f2da10288
3131
LSha1: a868fb6c0d95c48d037e9f08ce6e4200fd435fa4
3232
33-
Unlike some implementations of this hash, this one will not modify the buffer when calling digest(),
34-
so it is a safe operation. You can optionally pass finalize=True to the digest() call to override
35-
this behavior.
33+
Unlike some implementations of this hash, this one will not modify the object state when calling digest().
3634
"""
3735

3836

@@ -59,7 +57,7 @@ def debug(self):
5957
def digest(self):
6058
state = array.array('L', self._state)
6159

62-
if len(self._buffer) > 0:
60+
if self._position > 0:
6361
# There is uncommitted data, process it.
6462
block = bytearray(self._buffer)
6563
position = self._position

0 commit comments

Comments
 (0)