diff MoinMoin/security/textcha.py @ 5835:1ddf7d88c53d

fix issue with non-ascii textchas, hmac_new only takes str, not unicode
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 01 Mar 2012 00:15:41 +0100
parents e4479bf1c820
children 840ebd16ddd9
line wrap: on
line diff
--- a/MoinMoin/security/textcha.py	Wed Feb 22 17:36:25 2012 +0100
+++ b/MoinMoin/security/textcha.py	Thu Mar 01 00:15:41 2012 +0100
@@ -83,7 +83,8 @@
             return textchas[lang]
 
     def _compute_signature(self, question, timestamp):
-        return hmac_new(self.secret, "%s%d" % (question, timestamp)).hexdigest()
+        signature = u"%s%d" % (question, timestamp)
+        return hmac_new(self.secret, signature.encode('utf-8')).hexdigest()
 
     def _init_qa(self, question=None):
         """ Initialize the question / answer.