Python modules you should know: Pwtools

May 01, 2012 at 12:39 PM | categories: Python, PyMYSK, Howto | View Comments

Next in our series of Python modules you should know is Pwtools. This package is used to generate and test passwords in Python programs.

Home page

Use

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.

The algorithms used were borrowed from the Openwall Project’s passwdqc project, but have been re-implemented in Python for increased portability.

Installation

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

Usage

Generate a strong password:

from pwtools import PasswordGenerator
pwgen = PasswordGenerator()
pwgen.generate()

Output:

'amaze*Period&Thirst'

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')

Output:

'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