diff options
author | Aaron LI <aly@aaronly.me> | 2019-09-22 11:36:30 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2019-09-22 11:36:30 +0800 |
commit | 3a46c140fe496dba09726ffe31995bce92cad07f (patch) | |
tree | 75fe31dad5d9c8457e80e545f35c3b2df1b95e65 | |
parent | 551a067e37b4aaf9dce260460ce50dc69360da9d (diff) | |
download | ansible-dfly-vps-3a46c140fe496dba09726ffe31995bce92cad07f.tar.bz2 |
filter_plugins/passwd: Fix encode/decode for python3
-rw-r--r-- | filter_plugins/passwd.py | 6 |
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) |