def compare(string1, string2):
if len(string1) != len(string2):<EOL><INDENT>return False<EOL><DEDENT>result = True<EOL>for c1, c2 in izip(string1, string2):<EOL><INDENT>result &= c1 == c2<EOL><DEDENT>return result<EOL>
Compare two strings while protecting against timing attacks

    :param str string1: the first string
    :param str string2: the second string

    :returns: True if the strings are equal, False if not
    :rtype: :obj:`bool`