Simple password validator using raw entropy values, written in V.
Heavily influenced by go-password-validator
import xy3.passwordvalidator
fn main(){
entropy := passwordvalidator.get_entropy("a longer password")
// entropy is a f64, representing the strength in base 2 (bits)
min_entropy_bits := 60
passwordvalidator.validate("some password", min_entropy_bits) or { panic(err) }
// if the password has enough entropy, nothing is returned
// otherwise, a formatted error message is provided explaining
// how to increase the strength of the password
// (safe to show to the client)
}
It's up to you. That said, here is a graph that shows some common timings for different values, somewhere in the 50-70 range seems "reasonable".
Keep in mind that attackers likely aren't just brute-forcing passwords, if you want protection against common passwords or PWNed passwords you'll need to do additional work. This library is lightweight, doesn't load large datasets, and doesn't contact external services.