From 7ad82d0366a352055316c0e2de22dc9abdd292a4 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Fri, 8 Feb 2013 06:31:13 +0100 Subject: corrected MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- python3/sha3sum.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'python3') 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 . 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: -- cgit v1.2.3-70-g09d2