aboutsummaryrefslogtreecommitdiffstats
path: root/python3
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-02-08 06:31:13 +0100
committerMattias Andrée <maandree@operamail.com>2013-02-08 06:31:13 +0100
commit7ad82d0366a352055316c0e2de22dc9abdd292a4 (patch)
tree5c5b967487e8d9a157b5c29feee898cf302472ff /python3
parentm (diff)
downloadsha3sum-7ad82d0366a352055316c0e2de22dc9abdd292a4.tar.gz
sha3sum-7ad82d0366a352055316c0e2de22dc9abdd292a4.tar.bz2
sha3sum-7ad82d0366a352055316c0e2de22dc9abdd292a4.tar.xz
corrected
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-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: