Preview
Open Original
If you want to not leak length, compare a pre-hashed value. Attacker can know how long to hash their input but (and use a timing-safe comparision for the hashes; somewhere else has a hash + random salt method that doesn’t require a timing safe equals since the target value is randomly permutated) can’t know how even how long the target string is.