Skip to content

Commit b6ae98a

Browse files
author
Richard Jones
committed
added MD5 scheme for password hiding
1 parent d74e339 commit b6ae98a

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

CHANGES.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
This file contains the changes to the Roundup system over time. The entries
22
are given with the most recent entry first.
33

4+
2004-05-?? 0.8.0
5+
Feature:
6+
- added MD5 scheme for password hiding
7+
8+
49
2004-05-10 0.7.1
510
Fixed:
611
- several temp files made it into the source distribution (sf bug 949243)

roundup/password.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616
# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717
#
18-
# $Id: password.py,v 1.12 2004-03-22 07:45:39 richard Exp $
18+
# $Id: password.py,v 1.13 2004-05-10 22:32:17 richard Exp $
1919

2020
"""Password handling (encoding, decoding).
2121
"""
2222
__docformat__ = 'restructuredtext'
2323

24-
import sha, re, string, random
24+
import sha, md5, re, string, random
2525
try:
2626
import crypt
2727
except:
@@ -39,6 +39,8 @@ def encodePassword(plaintext, scheme, other=None):
3939
plaintext = ""
4040
if scheme == 'SHA':
4141
s = sha.sha(plaintext).hexdigest()
42+
elif scheme == 'MD5':
43+
s = md5.md5(plaintext).hexdigest()
4244
elif scheme == 'crypt' and crypt is not None:
4345
if other is not None:
4446
salt = other[:2]
@@ -59,8 +61,8 @@ def generatePassword(length=8):
5961
class Password:
6062
'''The class encapsulates a Password property type value in the database.
6163
62-
The encoding of the password is one if None, 'SHA' or 'plaintext'. The
63-
encodePassword function is used to actually encode the password from
64+
The encoding of the password is one if None, 'SHA', 'MD5' or 'plaintext'.
65+
The encodePassword function is used to actually encode the password from
6466
plaintext. The None encoding is used in legacy databases where no
6567
encoding scheme is identified.
6668
@@ -142,6 +144,13 @@ def test():
142144
assert 'sekrit' == p
143145
assert 'not sekrit' != p
144146

147+
# MD5
148+
p = Password('sekrit', 'MD5')
149+
assert p == 'sekrit'
150+
assert p != 'not sekrit'
151+
assert 'sekrit' == p
152+
assert 'not sekrit' != p
153+
145154
# crypt
146155
p = Password('sekrit', 'crypt')
147156
assert p == 'sekrit'

0 commit comments

Comments
 (0)