comparison MoinMoin/security/textcha.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 e1e9c0f9d7dd
children 561b7a9c2bd9
comparison
equal deleted inserted replaced
6102:df21062e294d 6103:500f68d3e2fd
17 * make similar changes to GUI editor 17 * make similar changes to GUI editor
18 18
19 @copyright: 2007 by MoinMoin:ThomasWaldmann 19 @copyright: 2007 by MoinMoin:ThomasWaldmann
20 @license: GNU GPL, see COPYING for details. 20 @license: GNU GPL, see COPYING for details.
21 """ 21 """
22 22 import hmac
23 import re 23 import re
24 import random 24 import random
25 25
26 from time import time 26 from time import time
27 27
28 from MoinMoin import log 28 from MoinMoin import log
29 logging = log.getLogger(__name__) 29 logging = log.getLogger(__name__)
30 30
31 from MoinMoin import wikiutil 31 from MoinMoin import wikiutil
32 from werkzeug.security import safe_str_cmp as safe_str_equal 32 from werkzeug.security import safe_str_cmp as safe_str_equal
33 from MoinMoin.support.python_compatibility import hmac_new
34 33
35 SHA1_LEN = 40 # length of hexdigest 34 SHA1_LEN = 40 # length of hexdigest
36 TIMESTAMP_LEN = 10 # length of timestamp 35 TIMESTAMP_LEN = 10 # length of timestamp
37 36
38 class TextCha(object): 37 class TextCha(object):
83 logging.debug(u"TextCha: using lang = '%s'" % lang) 82 logging.debug(u"TextCha: using lang = '%s'" % lang)
84 return textchas[lang] 83 return textchas[lang]
85 84
86 def _compute_signature(self, question, timestamp): 85 def _compute_signature(self, question, timestamp):
87 signature = u"%s%d" % (question, timestamp) 86 signature = u"%s%d" % (question, timestamp)
88 return hmac_new(self.secret, signature.encode('utf-8')).hexdigest() 87 return hmac.new(self.secret, signature.encode('utf-8')).hexdigest()
89 88
90 def _init_qa(self, question=None): 89 def _init_qa(self, question=None):
91 """ Initialize the question / answer. 90 """ Initialize the question / answer.
92 91
93 @param question: If given, the given question will be used. 92 @param question: If given, the given question will be used.