[Zope] Random Password Generator
Dario Lopez-Kästen
dario@ita.chalmers.se
Mon, 17 Feb 2003 15:41:17 +0100
From: "Asad Habib" <ahabib1357@yahoo.com>
> Hello. Does anyone know if there are any built-in
> Python methods which allow you to generate passwords
> randomly? Any help would be greatly appreciated.
> Thanks.
>
> -Asad
----------
def generatePassword(self, pwdLen=8):
# Returns a random password.
import random
random.seed()
passwd= ''
# Since I, 1 ~= l and 0 =~ O, don't generate passwords with them.
# This will just confuse people using ugly fonts.
charset = 'abcdefghijkmnopqrstuxyzABCDEFGHJKLMNPQRSTUXYZ0123456789'
for i in range(pwdLen):
passwd = passwd + random.choice(charset)
return passwd
--------
Add/remove characters from charset if needed.
Can probably be re-written as a "Script (Python)". If not use as external
method. Cannot vouch for it's non-symmetric-ness (or however that word is
spelled, if it even exists, but you get my point... :-)
Hop this helps,
/dario
- --------------------------------------------------------------------
Dario Lopez-Kästen, IT Systems & Services Chalmers University of Tech.