comparison roundup/password.py @ 1616:6d1af2e441f4 maint-0.5

email registered users shouldn't be able to log in [SF#714673]
author Richard Jones <richard@users.sourceforge.net>
date Thu, 24 Apr 2003 07:51:52 +0000
parents 83f33642d220
children
comparison
equal deleted inserted replaced
1610:d4f4061e6d1d 1616:6d1af2e441f4
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.8.2.1 2003-04-24 07:49:33 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

Roundup Issue Tracker: http://roundup-tracker.org/