7 comments

[ 3.1 ms ] story [ 28.6 ms ] thread
so hash(input) == hash(secret) ?
No, `hash(hash(input)) == hash(hash(secret))`.
No, `hmac(key=key, message=input) == hmac(key=key, message=secret)` where key is either a static secret key for comparison purposes, or random for each comparison.
Neat idea! Especially on jitted platforms where the jit is likely to introduce a timing side channel.
Using the timingsafe_memcmp C function would be faster and safer.