def auth_str_equal(provided, known):
 result = 0
 p_len = len(provided)
 k_len = len(known)
 for i in xrange(p_len):
  a = (ord(provided[i]) if (i < p_len) else 0)
  b = (ord(known[i]) if (i < k_len) else 0)
  result |= (a ^ b)
 return ((p_len == k_len) & (result == 0))

def auth_str_equal ( provided , known ) : result = 0 p_len = len ( provided ) k_len = len ( known ) for i in xrange ( p_len ) : a = ( ord ( provided [ i ] ) if ( i < p_len ) else 0 ) b = ( ord ( known [ i ] ) if ( i < k_len ) else 0 ) result |= ( a ^ b ) return ( ( p_len == k_len ) & ( result == 0 ) )
constant-time string comparison .