aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2019-09-22 11:36:30 +0800
committerAaron LI <aly@aaronly.me>2019-09-22 11:36:30 +0800
commit3a46c140fe496dba09726ffe31995bce92cad07f (patch)
tree75fe31dad5d9c8457e80e545f35c3b2df1b95e65
parent551a067e37b4aaf9dce260460ce50dc69360da9d (diff)
downloadansible-dfly-vps-3a46c140fe496dba09726ffe31995bce92cad07f.tar.bz2
filter_plugins/passwd: Fix encode/decode for python3
-rw-r--r--filter_plugins/passwd.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/filter_plugins/passwd.py b/filter_plugins/passwd.py
index 40536f4..f73a5ac 100644
--- a/filter_plugins/passwd.py
+++ b/filter_plugins/passwd.py
@@ -19,7 +19,7 @@ def cryptpass(p):
hashtype = "$6$"
saltlen = 16
salt = os.urandom(saltlen)
- salt = base64.b64encode(salt)[:saltlen]
+ salt = base64.b64encode(salt)[:saltlen].decode("utf-8")
return crypt.crypt(p, hashtype+salt)
@@ -46,9 +46,9 @@ def znc_makepass(p, method="sha256", saltlen=20):
ZNC password format: <method>#<hash>#<salt>
"""
salt = os.urandom(saltlen)
- salt = base64.b64encode(salt)[:saltlen]
+ salt = base64.b64encode(salt)[:saltlen].decode("utf-8")
s = p + salt
- h = getattr(hashlib, method)(s)
+ h = getattr(hashlib, method)(s.encode("utf-8"))
return "%s#%s#%s" % (method, h.hexdigest(), salt)