Skip to main content

Python implementation of Dropbox's realistic password strength estimator, zxcvbn

Project description

Build Status

zxcvbn-python

A realistic password strength estimator.

This is a Python implementation of the library created by the team at Dropbox. The original library, written for JavaScript, can be found here.

While there may be other Python ports available, this one is the most up to date and is recommended by the original developers of zxcvbn at this time.

Features

  • Tested in Python versions 2.6-2.7, 3.3-3.6

  • Accepts user data to be added to the dictionaries that are tested against (name, birthdate, etc)

  • Gives a score to the password, from 0 (terrible) to 4 (great)

  • Provides feedback on the password and ways to improve it

  • Returns time estimates on how long it would take to guess the password in different situations

Installation

Install the package using pip: pip install zxcvbn-python

Usage

Pass a password as the first parameter, and a list of user-provided inputs as the user_inputs parameter (optional).

from zxcvbn import zxcvbn

results = zxcvbn('JohnSmith123', user_inputs=['John', 'Smith'])

print(results)

Output:

{
    'password': 'JohnSmith123',
    'score': 2,
    'guesses': 2567800,
    'guesses_log10': 6.409561194521849,
    'calc_time': datetime.timedelta(0, 0, 5204)
    'feedback': {
        'warning': '',
        'suggestions': [
            'Add another word or two. Uncommon words are better.',
            "Capitalization doesn't help very much"
        ]
    },
    'crack_times_display': {
        'offline_fast_hashing_1e10_per_second': 'less than a second'
        'offline_slow_hashing_1e4_per_second': '4 minutes',
        'online_no_throttling_10_per_second': '3 days',
        'online_throttling_100_per_hour': '3 years',
    },
    'crack_times_seconds': {
        'offline_fast_hashing_1e10_per_second': 0.00025678,
        'offline_slow_hashing_1e4_per_second': 256.78
        'online_no_throttling_10_per_second': 256780.0,
        'online_throttling_100_per_hour': 92440800.0,
    },
    'sequence': [{
        'matched_word': 'john',
        'rank': 2,
        'pattern': 'dictionary',
        'reversed': False,
        'token': 'John',
        'l33t': False,
        'uppercase_variations': 2,
        'i': 0,
        'guesses': 50,
        'l33t_variations': 1,
        'dictionary_name': 'male_names',
        'base_guesses': 2,
        'guesses_log10': 1.6989700043360185,
        'j': 3
    }, {
        'matched_word': 'smith123',
        'rank': 12789,
        'pattern': 'dictionary',
        'reversed': False,
        'token': 'Smith123',
        'l33t': False,
        'uppercase_variations': 2,
        'i': 4,
        'guesses': 25578,
        'l33t_variations': 1,
        'dictionary_name': 'passwords',
        'base_guesses': 12789,
        'guesses_log10': 4.407866583030775,
        'j': 11
    }],
}

Custom Ranked Dictionaries

In order to support more languages or just add password dictionaries of your own, there is a helper function you may use.

from zxcvbn.matching import add_frequency_lists

add_frequency_lists({
    'my_list': ['foo', 'bar'],
    'another_list': ['baz']
})

These lists will be added to the current ones, but you can also overwrite the current ones if you wish. The lists you add should be in order of how common the word is used with the most common words appearing first.

Contribute

License

The project is licensed under the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zxcvbn-python-4.4.14.tar.gz (405.1 kB view details)

Uploaded Source

File details

Details for the file zxcvbn-python-4.4.14.tar.gz.

File metadata

  • Download URL: zxcvbn-python-4.4.14.tar.gz
  • Upload date:
  • Size: 405.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for zxcvbn-python-4.4.14.tar.gz
Algorithm Hash digest
SHA256 fd3a46536035851571e3f4142b64d6e7bcf0ade3cd40d8fecae7a1243945e327
MD5 5c41b2ea7b7421a8f8da505bbba3bbd4
BLAKE2b-256 e956eea9cf0fab96ad354d091ee05a38f037d6df8765b4e6cba3f6a812ff87f3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page