diff options
author | Mattias Andrée <maandree@operamail.com> | 2013-08-10 07:34:44 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2013-08-10 07:34:44 +0200 |
commit | 4ad06d62e83011d808ca75a1c49ac70095f3e09d (patch) | |
tree | 5eb323855059566285a8c0ba472a71cbe14d6922 /python2/sha3sum.py | |
parent | m (diff) | |
download | sha3sum-4ad06d62e83011d808ca75a1c49ac70095f3e09d.tar.gz sha3sum-4ad06d62e83011d808ca75a1c49ac70095f3e09d.tar.bz2 sha3sum-4ad06d62e83011d808ca75a1c49ac70095f3e09d.tar.xz |
apply changes made in python3 to python2 version
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'python2/sha3sum.py')
-rwxr-xr-x | python2/sha3sum.py | 29 |
1 files changed, 15 insertions, 14 deletions
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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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 <http://www.gnu.org/licenses/>. 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: |