From 4ad06d62e83011d808ca75a1c49ac70095f3e09d Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 10 Aug 2013 07:34:44 +0200 Subject: apply changes made in python3 to python2 version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- python2/sha3sum.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'python2/sha3sum.py') diff --git a/python2/sha3sum.py b/python2/sha3sum.py index ac80fbe..9bb04ed 100755 --- a/python2/sha3sum.py +++ b/python2/sha3sum.py @@ -288,13 +288,14 @@ along with this program. If not, see . sys.exit(3) stdin = None fail = False + sha = SHA3() for filename in files: rc = '' fn = '/dev/stdin' if filename is None else filename with open(fn, 'rb') as file: try: if (filename is not None) or (stdin is None): - SHA3.initialise(r, c, o) + sha.initialise(r, c, o) blksize = 4096 try: blksize = os.stat(os.path.realpath(fn)).st_blksize @@ -307,7 +308,7 @@ along with this program. If not, see . if len(chunk) == 0: break if not hex: - SHA3.update(chunk) + sha.update(chunk) else: n = len(chunk) >> 1 for _ in range(n): @@ -315,24 +316,24 @@ along with this program. If not, see . a = ((a & 15) + (0 if a <= '9' else 9)) << 4 b = (b & 15) + (0 if b <= '9' else 0) chunk[_] = a | b - SHA3.update(chunk, n) - bs = SHA3.digest(j == 1) + sha.update(chunk, n) + bs = sha.digest(j == 1) if j > 2: - SHA3.fastSqueeze(j - 2) + sha.fastSqueeze(j - 2) if j > 1: - bs = SHA3.squeeze(); + bs = sha.squeeze(); if filename is None: stdin = bs else: bs = stdin if multi == 0: for _ in range(i - 1): - SHA3.initialise(r, c, o) - bs = SHA3.digest(bs, j == 1) + sha.initialise(r, c, o) + bs = sha.digest(bs, j == 1) if j > 2: - SHA3.fastSqueeze(j - 2) + sha.fastSqueeze(j - 2) if j > 1: - bs = SHA3.squeeze(); + bs = sha.squeeze(); if binary: write(bs) else: @@ -351,12 +352,12 @@ along with this program. If not, see . rc += '\n' write(rc.encode('UTF-8')) for _ in range(i - 1): - SHA3.initialise(r, c, o) - bs = SHA3.digest(bs, j == 1) + sha.initialise(r, c, o) + bs = sha.digest(bs, j == 1) if j > 2: - SHA3.fastSqueeze(j - 2) + sha.fastSqueeze(j - 2) if j > 1: - bs = SHA3.squeeze(); + bs = sha.squeeze(); if binary: write(bs); else: -- cgit v1.2.3-70-g09d2