add timing safe string compare method

Supercedes #688. Adds a constant-time string compare method, suited for comparing digests.