aboutsummaryrefslogtreecommitdiffstats
path: root/src/python/botan2.py
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-08-11 18:11:56 -0400
committerJack Lloyd <[email protected]>2018-08-11 18:11:56 -0400
commit24963a27f6f5e2235f00ef7463f039bceac548b3 (patch)
treec32e9c16277325ae78b774ba6b10a9c79faa28cb /src/python/botan2.py
parentcb05f9c9938434c0c56122addd94015e7df38b19 (diff)
Fix Python2 problem
Diffstat (limited to 'src/python/botan2.py')
-rwxr-xr-xsrc/python/botan2.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/python/botan2.py b/src/python/botan2.py
index 617efa887..209805a66 100755
--- a/src/python/botan2.py
+++ b/src/python/botan2.py
@@ -395,6 +395,12 @@ def _ctype_str(s):
else:
return s.encode('utf-8')
+def _ctype_to_str(s):
+ if version_info[0] < 3:
+ return s.encode('utf-8')
+ else:
+ return s.decode('utf-8')
+
def _ctype_bits(s):
if version_info[0] < 3:
if isinstance(s, str):
@@ -608,7 +614,7 @@ def bcrypt(passwd, rng_instance, work_factor=10):
b = out.raw[0:int(out_len.value)-1]
if b[-1] == '\x00':
b = b[:-1]
- return b.decode('ascii')
+ return _ctype_to_str(b)
def check_bcrypt(passwd, passwd_hash):
rc = botan.botan_bcrypt_is_valid(_ctype_str(passwd), _ctype_str(passwd_hash))