rails/rails — pull request #9230 by homakov (2013-02-09 12:23:03+00:00)
Title: making secure_compare 40-50 times faster

https://gist.github.com/homakov/4745028

how it works: we use .hash which is super fast, so we know that strings are different super fast too.
Even if strings hashes are just collisions we use compare with ==, which is also much faster than current iteration.
timing attack makes no sense for hash based comparison.