aboutsummaryrefslogtreecommitdiffstats
path: root/python3/sha3sum.py
diff options
context:
space:
mode:
Diffstat (limited to 'python3/sha3sum.py')
-rwxr-xr-xpython3/sha3sum.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/python3/sha3sum.py b/python3/sha3sum.py
index f7e297a..613b697 100755
--- a/python3/sha3sum.py
+++ b/python3/sha3sum.py
@@ -324,7 +324,7 @@ class SHA3:
@param r:int The bitrate
@return :str The message padded
'''
- nnn = len(msg)
+ nnn = len(msg) << 3
nrf = nnn >> 3
nbrf = nnn & 7
@@ -341,8 +341,6 @@ class SHA3:
message = [0] * (nnn - nrf)
message[0] = bbbb
nnn -= nrf
- #for i in range(1, nnn):
- # message[i] = 0
message[nnn - 1] = 0x80
return msg[:nrf] + bytes(message)
@@ -698,7 +696,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
fn = '/dev/stdin' if filename is None else filename
with open(fn, 'rb') as file:
SHA3.initialise(r, c, o)
- blksize = os.stat(os.path.realpath(fn)).st_size
+ blksize = (o + 7) >> 3
+ try:
+ blksize = os.stat(os.path.realpath(fn)).st_size
+ except:
+ pass
while True:
chunk = file.read(blksize)
if len(chunk) == 0: