more tweaks for python3
[plcapi.git] / PLC / Persons.py
index d24597a..bc4b4c1 100644 (file)
@@ -5,10 +5,7 @@
 # Copyright (C) 2006 The Trustees of Princeton University
 #
 
-try:
-    from hashlib import md5
-except ImportError:
-    from md5 import md5
+from hashlib import md5
 import time
 from random import Random
 import re
@@ -113,8 +110,8 @@ class Person(Row):
         else:
             # Generate a somewhat unique 8 character salt string
             salt = str(time.time()) + str(Random().random())
-            salt = md5(salt).hexdigest()[:8]
-            return crypt.crypt(password.encode(self.api.encoding), magic + salt + "$")
+            salt = md5(salt.encode()).hexdigest()[:8]
+            return crypt.crypt(password, magic + salt + "$")
 
     validate_date_created = Row.validate_timestamp
     validate_last_updated = Row.validate_timestamp