Mercurial > p > roundup > code
comparison roundup/password.py @ 1583:caae7d8934dc
set new email rego user password to random string
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Thu, 10 Apr 2003 05:12:42 +0000 |
| parents | 2e557762ee87 |
| children | dc43e339e607 |
comparison
equal
deleted
inserted
replaced
| 1582:54f7717ece32 | 1583:caae7d8934dc |
|---|---|
| 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | 13 # BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" | 14 # FOR A PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" |
| 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, | 15 # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, |
| 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 16 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 17 # | 17 # |
| 18 # $Id: password.py,v 1.8 2002-12-18 23:57:09 richard Exp $ | 18 # $Id: password.py,v 1.9 2003-04-10 05:12:41 richard Exp $ |
| 19 | 19 |
| 20 __doc__ = """ | 20 __doc__ = """ |
| 21 Password handling (encoding, decoding). | 21 Password handling (encoding, decoding). |
| 22 """ | 22 """ |
| 23 | 23 |
| 24 import sha, re, string | 24 import sha, re, string, random |
| 25 try: | 25 try: |
| 26 import crypt | 26 import crypt |
| 27 except: | 27 except: |
| 28 crypt = None | 28 crypt = None |
| 29 pass | 29 pass |
| 45 elif scheme == 'plaintext': | 45 elif scheme == 'plaintext': |
| 46 s = plaintext | 46 s = plaintext |
| 47 else: | 47 else: |
| 48 raise ValueError, 'Unknown encryption scheme "%s"'%scheme | 48 raise ValueError, 'Unknown encryption scheme "%s"'%scheme |
| 49 return s | 49 return s |
| 50 | |
| 51 def generatePassword(length=8): | |
| 52 chars = string.letters+string.digits | |
| 53 return ''.join([random.choice(chars) for x in range(length)]) | |
| 50 | 54 |
| 51 class Password: | 55 class Password: |
| 52 '''The class encapsulates a Password property type value in the database. | 56 '''The class encapsulates a Password property type value in the database. |
| 53 | 57 |
| 54 The encoding of the password is one if None, 'SHA' or 'plaintext'. The | 58 The encoding of the password is one if None, 'SHA' or 'plaintext'. The |
