test, and password generator
Will Ware
wware at alum.mit.edu
Mon Aug 27 22:48:56 EDT 2001
I'm tinkering with my email and usenet service, for which this is
a test. ObPython follows.
#!/usr/bin/env python
# handy password generator
import random, math
if 0:
# short, cryptic passwords with rich character set
# To avoid confusion, leave out 0, O, 1, and l.
units = "ABCDEFGHIJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789"
units = units + """!@#$%^&*+=;:,.""" # Compensate with punctuation.
separator = ""
elif 1:
# short cryptic passwords with lowercase and digits only
units = "abcdefghijkmnopqrstuvwxyz0123456789"
separator = ""
else:
# long passwords made from real words
# These are OK with Unix, bad with Windows.
units = [ ]
separator = "-"
inf = open("/usr/dict/words")
for x in inf.readlines():
units.append(x[:-1])
inf.close()
length = 10
e = length * math.log(len(units)) / math.log(2)
print "Entropy is %g bits" % e
# Assume the attacker attempts 100 logins per second, but can't get
# access to /etc/passwd or /etc/shadow. Then...
print "Cracking time is", (0.01 * 2**e) / (3600 * 24 * 365.24), "years"
pw = ""
for i in range(length):
pw = pw + random.choice(units) + separator
if len(separator):
pw = pw[:-len(separator)]
print "Password:", pw
More information about the Python-list
mailing list