[crypto] Encode unicode strings in _cypherer()
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Tue, 21 May 2019 10:18:38 +0200
changeset 12619 48a010b35af2
parent 12614 8ac9ac8d9143
child 12620 824105876352
[crypto] Encode unicode strings in _cypherer() pycrypto accept both bytes or string but pycryptodome, which will be introduced in next changeset, doesn't accept this. For backward compatibility, encode unicode strings in _cypherer()
cubicweb/crypto.py
--- a/cubicweb/crypto.py	Thu May 16 04:42:59 2019 +0200
+++ b/cubicweb/crypto.py	Tue May 21 10:18:38 2019 +0200
@@ -26,6 +26,8 @@
 
 _CYPHERERS = {}
 def _cypherer(seed):
+    if isinstance(seed, str):
+        seed = seed.encode('utf-8')
     try:
         return _CYPHERERS[seed]
     except KeyError: