Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Function for constant time string comparison.
def is_equal(a, b):
if len(a) != len(b):
return False
result = 0
for x, y in zip(a, b):
result |= x ^ y
return result == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment