Skip to content

Instantly share code, notes, and snippets.

@chemputer
Last active April 16, 2020 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chemputer/2f22727e3744adfa5f0c94e1c6aa0a9d to your computer and use it in GitHub Desktop.
Save chemputer/2f22727e3744adfa5f0c94e1c6aa0a9d to your computer and use it in GitHub Desktop.
Python Interactive zxcvbn Password Checker

This is a simple password checker based on zxcvbn. It's simple, short program that you can use to easily check your passwords on a local machine, rather than using a website that promises it's definitely not storing your passwords.

The only main prerequisite is zxcvbn, which can be installed by either: python3 -m pip install zxcvbn or pip3 install zxcvbn

Then you simply need to execute the program. The program will ask you for a password, which you type into the terminal. It will keep looping, over and over, until you enter exit, quit, or stop as the password.

Then, it will return a formatted list of attributes about said password. For example, the password 1234 I am a Gistgives the following:

 Password:1234 I am a Gist
{'calc_time': datetime.timedelta(microseconds=4421),
 'crack_times_display': {'offline_fast_hashing_1e10_per_second': '3 hours',
                         'offline_slow_hashing_1e4_per_second': 'centuries',
                         'online_no_throttling_10_per_second': 'centuries',
                         'online_throttling_100_per_hour': 'centuries'},
 'crack_times_seconds': {'offline_fast_hashing_1e10_per_second': Decimal('10000.000001'),
                         'offline_slow_hashing_1e4_per_second': Decimal('10000000001'),
                         'online_no_throttling_10_per_second': Decimal('10000000001000'),
                         'online_throttling_100_per_hour': Decimal('3600000000360000.199840144453')},
 'feedback': {'suggestions': [], 'warning': ''},
 'guesses': Decimal('100000000010000'),
 'guesses_log10': 14.00000000004343,
 'password': '1234 I am a Gist',
 'score': 4,
 'sequence': [{'base_guesses': 7,
               'dictionary_name': 'passwords',
               'guesses': 50,
               'guesses_log10': 1.6989700043360185,
               'i': 0,
               'j': 3,
               'l33t': False,
               'l33t_variations': 1,
               'matched_word': '1234',
               'pattern': 'dictionary',
               'rank': 7,
               'reversed': False,
               'token': '1234',
               'uppercase_variations': 1},
              {'guesses': 1000000000000,
               'guesses_log10': 11.999999999999998,
               'i': 4,
               'j': 15,
               'pattern': 'bruteforce',
               'token': ' I am a Gist'}]}
#!/usr/bin/python3
from pprint import pprint
# shorten zxcvbn to just z to be easier to use
# install zxcvbn by running python3 -m pip install zxcvbn, or pip3 install zxcvbn
from zxcvbn import zxcvbn as z
def main():
# get input from user, store password as a string
p = input('''Input any password to check it's strength with zxcvbn.
\n The program will loop forever,
\n\t to exit, type 'exit', 'quit', or 'stop'.
\n Password:''')
# put the stored password through zxcvbn password analyzer, and pretty print the output
# keep doing that until the user enters exit, quit, or stop
pprint(z(str(p)))
if p.lower() == "exit" or p.lower == "exit()" or p.lower() == "quit" or p.lower() == "stop":
exit()
# infinite loop until user quits
while True:
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment