aboutsummaryrefslogtreecommitdiffstats
path: root/python3/sha3sum.py
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-04-16 00:06:18 +0200
committerMattias Andrée <maandree@operamail.com>2013-04-16 00:06:18 +0200
commit90258fdadace50db3ef72a46aa84e9004c7cb61a (patch)
tree4813be3ed649b7bcdb4588aa6cc28613da80576d /python3/sha3sum.py
parentwhoops, read the filesize instead of the blocksize (diff)
downloadsha3sum-90258fdadace50db3ef72a46aa84e9004c7cb61a.tar.gz
sha3sum-90258fdadace50db3ef72a46aa84e9004c7cb61a.tar.bz2
sha3sum-90258fdadace50db3ef72a46aa84e9004c7cb61a.tar.xz
fix binary logarithm
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rwxr-xr-xpython3/sha3sum.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/python3/sha3sum.py b/python3/sha3sum.py
index 27b9fd1..e331df8 100755
--- a/python3/sha3sum.py
+++ b/python3/sha3sum.py
@@ -109,7 +109,12 @@ class SHA3:
@param x:int The value of which to calculate the binary logarithm
@return :int The binary logarithm
'''
- return ((0 if (x & 0xFF00) == 0 else 8) + (0 if (x & 0xF0F0) == 0 else 4)) + ((0 if (x & 0xCCCC) == 0 else 2) + (0 if (x & 0xAAAA) == 0 else 1))
+ rc = 0
+ if (x & 0xFF00) != 0: rc += 8 ; x >>= 8
+ if (x & 0x00F0) != 0: rc += 4 ; x >>= 4
+ if (x & 0x000C) != 0: rc += 2 ; x >>= 2
+ if (x & 0x0002) != 0: rc += 1
+ return rc
@staticmethod