--- hmac.py-orig 2007-11-06 06:32:04.000000000 +0600 +++ hmac.py 2008-04-24 17:49:29.000000000 +0600 @@ -3,10 +3,16 @@ Implements the HMAC algorithm as described by RFC 2104. """ +import array def _strxor(s1, s2): """Utility method. XOR the two strings s1 and s2 (must have same length). """ - return "".join(map(lambda x, y: chr(ord(x) ^ ord(y)), s1, s2)) + a1 = array.array('B') + a1.fromstring(s1) + a2 = array.array('B') + a2.fromstring(s2) + return array.array('B', [x ^ y for x, y in zip(a1, a2)]).tostring() + # The size of the digests returned by HMAC depends on the underlying # hashing module used.