pbkdf2-hmac-sha512: improved valid()