From 3a46c140fe496dba09726ffe31995bce92cad07f Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Sun, 22 Sep 2019 11:36:30 +0800 Subject: filter_plugins/passwd: Fix encode/decode for python3 --- filter_plugins/passwd.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'filter_plugins') 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: ## """ 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) -- cgit v1.2.2