diff MoinMoin/user.py @ 6103:500f68d3e2fd

remove our own usage of python_compatibility module
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 06 Sep 2016 01:00:25 +0200
parents 1306560f158e
children 561b7a9c2bd9
line wrap: on
line diff
--- a/MoinMoin/user.py	Tue Sep 06 00:26:46 2016 +0200
+++ b/MoinMoin/user.py	Tue Sep 06 01:00:25 2016 +0200
@@ -21,6 +21,8 @@
 """
 
 import os, time, codecs, base64
+import hashlib
+import hmac
 from copy import deepcopy
 import md5crypt
 
@@ -32,8 +34,6 @@
 from MoinMoin import log
 logging = log.getLogger(__name__)
 
-from MoinMoin.support.python_compatibility import hash_new, hmac_new
-
 from MoinMoin import config, caching, wikiutil, i18n, events
 from werkzeug.security import safe_str_cmp as safe_str_equal
 from MoinMoin.util import timefuncs, random_string
@@ -285,7 +285,7 @@
         if salt is None:
             salt = random_string(20)
         assert isinstance(salt, str)
-        hash = hash_new('sha1', pwd)
+        hash = hashlib.new('sha1', pwd)
         hash.update(salt)
         return '{SSHA}' + base64.encodestring(hash.digest() + salt).rstrip()
     else:
@@ -715,13 +715,13 @@
                     if scheme == '{SSHA}':
                         d = base64.decodestring(d)
                         salt = d[20:]
-                        hash = hash_new('sha1', password.encode('utf-8'))
+                        hash = hashlib.new('sha1', password.encode('utf-8'))
                         hash.update(salt)
                         enc = base64.encodestring(hash.digest() + salt).rstrip()
 
                     elif scheme == '{SHA}':
                         enc = base64.encodestring(
-                            hash_new('sha1', password.encode('utf-8')).digest()).rstrip()
+                            hashlib.new('sha1', password.encode('utf-8')).digest()).rstrip()
 
                     elif scheme == '{APR1}':
                         # d is of the form "$apr1$<salt>$<hash>"
@@ -1260,7 +1260,7 @@
     def generate_recovery_token(self):
         key = random_string(64, "abcdefghijklmnopqrstuvwxyz0123456789")
         msg = str(int(time.time()))
-        h = hmac_new(key, msg).hexdigest()
+        h = hmac.new(key, msg).hexdigest()
         self.recoverpass_key = key
         self.save()
         return msg + '-' + h
@@ -1278,7 +1278,7 @@
             return False
         # check hmac
         # key must be of type string
-        h = hmac_new(str(self.recoverpass_key), str(stamp)).hexdigest()
+        h = hmac.new(str(self.recoverpass_key), str(stamp)).hexdigest()
         if not safe_str_equal(h, parts[1]):
             return False
         self.recoverpass_key = ""