zxcvbn

4.5.0 · active · verified Thu Apr 09

zxcvbn is a Python implementation of Dropbox's realistic password strength estimator. It evaluates password strength based on pattern matching and conservative entropy calculations, providing a score (0-4), verbal feedback, and crack time estimates. The library is currently at version 4.5.0 and is actively maintained, though releases occur on an irregular cadence, typically spanning months to a year between major updates.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import and use the `zxcvbn` function to evaluate password strength. It shows a basic check and an example of providing `user_inputs` to improve the accuracy of the strength calculation by penalizing common user-related patterns in the password. The output includes a score, crack time estimates, and feedback.

from zxcvbn import zxcvbn

# Basic password strength check
results = zxcvbn('password123')
print(f"Password: {results['password']}")
print(f"Score: {results['score']} (0=terrible, 4=great)")
print(f"Crack time display: {results['crack_times_display']['offline_fast_hashing_1e10_per_second']}")
if results['feedback'] and results['feedback']['suggestions']:
    print("Suggestions:")
    for suggestion in results['feedback']['suggestions']:
        print(f"- {suggestion}")

# With user-provided inputs (e.g., username, name) to penalize matching patterns
user_inputs = ['John', 'Smith', 'jsmith']
results_with_user_input = zxcvbn('JohnSmith123', user_inputs=user_inputs)
print(f"\nPassword (with user inputs): {results_with_user_input['password']}")
print(f"Score: {results_with_user_input['score']}")
if results_with_user_input['feedback'] and results_with_user_input['feedback']['warning']:
    print(f"Warning: {results_with_user_input['feedback']['warning']}")

view raw JSON →