|
|
|
|
|
by iki23
5462 days ago
|
|
You can also initialize the words in more pythonic way: with open('/usr/share/dict/words') as wordlist:
words = set(line[:-1] for line in wordlist)
Or, for one time check you can stop reading on match: import sys
lookup = '%s\n' % sys.argv[1]
with open('/usr/share/dict/words') as wordlist:
[ sys.stdout.write('Dictionary password: %s' % lookup) or sys.exit(1) for line in wordlist if line == lookup ]
As for the objective, this checks only exact dictionary matches. In real world, you'd use cracklib to check any dictionary based or weak passwords rather than reinvent the wheel. See http://gdub.wordpress.com/2006/08/26/using-cracklib-to-requi... |
|