From c7d0d7c3b6cf4825947e56dfd69531be4b7f28c3 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Mon, 4 Feb 2013 02:45:49 +0100 Subject: small rotation optimisation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- sha3sum.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sha3sum.py b/sha3sum.py index 35b71dd..b79c4d4 100755 --- a/sha3sum.py +++ b/sha3sum.py @@ -85,7 +85,8 @@ class SHA3: @param n:int Rotation steps @return :int The value rotated ''' - return ((x >> (SHA3.w - (n % SHA3.w))) + (x << (n % SHA3.w))) & SHA3.wmod + m = n % SHA3.w + return ((x >> (SHA3.w - m)) + (x << m)) & SHA3.wmod @staticmethod -- cgit v1.2.3-70-g09d2