Mercurial > p > roundup > code
diff roundup/password.py @ 4760:efdce3d32698
Increase generated password length to 12 symbols.
Make sure at least one digit is present.
See article of Georgia Tech Research Institute at
http://goo.gl/olFxy for more information.
| author | anatoly techtonik <techtonik@gmail.com> |
|---|---|
| date | Mon, 18 Feb 2013 00:42:08 +0300 |
| parents | 2f66d44616ad |
| children | 9ba03348f923 |
line wrap: on
line diff
--- a/roundup/password.py Tue Feb 05 15:06:10 2013 +0530 +++ b/roundup/password.py Mon Feb 18 00:42:08 2013 +0300 @@ -165,9 +165,13 @@ raise PasswordValueError, 'Unknown encryption scheme %r'%scheme return s -def generatePassword(length=8): +def generatePassword(length=12): chars = string.letters+string.digits - return ''.join([random.choice(chars) for x in range(length)]) + password = [random.choice(chars) for x in range(length)] + # make sure there is at least one digit + password[0] = random.choice(string.digits) + random.shuffle(password) + return ''.join(password) class JournalPassword: """ Password dummy instance intended for journal operation.
