Alastair’s Place

Software development, Cocoa, Objective-C, life. Stuff like that.

Pwtools

Simple password generation and testing

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.

Usage

To generate a secure password:

1
2
3
4
>>> import pwtools
>>> pwgen = pwtools.PasswordGenerator()
>>> pwgen.generate()
'Arctic9these9meat'

To check a password:

1
2
3
4
5
6
7
>>> pwcheck = pwtools.PasswordChecker('/usr/share/dict/words')
>>> pwcheck.checkPassword('foobar')
'too simple (not enough different kinds of character)'
>>> pwcheck.checkPassword('123456abcdef')
'based on a common sequence of characters'
>>> pwcheck.checkPassword('4lt3rC47!0n') # leet for altercation
'based on a dictionary word'

Download

You can grab the sources from the mercurial repository. There is also a Python egg and a tar file.

(Version 0.4 includes an updated word set.)