Next in our series of Python modules you should know is Pwtools. This package is used to generate and test passwords in Python programs.
pwtools is a Python package that provides the ability to generate passwords, and also allows you to test them to ensure that they are reasonably secure.
This package is not available on the cheeseshop (PYPI) so you need to install it from the Mercurial repository.
pip install hg+http://alastairs-place.net/hg/pwtools
Generate a strong password:
from pwtools import PasswordGenerator pwgen = PasswordGenerator() pwgen.generate()
Check password strength:
from pwtools import PasswordChecker pwchecker = PasswordChecker('/usr/share/dict/words') pwchecker.checkPassword('password') pwchecker.checkPassword('zxcvbnm') pwchecker.checkPassword('123456abcdef') pwchecker.checkPassword('m1ll10n') pwchecker.checkPassword('amaze*Period&Thirst')
'too simple (not enough different kinds of character)' 'too simple (not enough different kinds of character)' 'based on a common sequence of characters' 'too simple (not enough different kinds of character)' False
blog comments powered by Disqus