From ea77d5d948221109872ba855bfd8faf80a9630b6 Mon Sep 17 00:00:00 2001 From: ix5 Date: Wed, 23 Feb 2022 23:10:52 +0100 Subject: [PATCH] utils: hash: Use hashlib for pbkdf2 !!! This is a backport of a commit from the master branch to fix compatibility with werkzeug 2.1+ !!! werkzeug 2.1 will deprecate `pbkdf2_bin` and recommends pbkdf2_hmac as an alternative. Adjust function invocation and use named args to avoid confusion. Compare: https://werkzeug.palletsprojects.com/en/2.0.x/utils/#werkzeug.security.pbkdf2_bin -> Will be gone in werkzeug 2.1 https://docs.python.org/3/library/hashlib.html#hashlib.pbkdf2_hmac -> Available since Python 3.4 --- isso/utils/hash.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/isso/utils/hash.py b/isso/utils/hash.py index 111916eac..58a953b36 100644 --- a/isso/utils/hash.py +++ b/isso/utils/hash.py @@ -3,7 +3,7 @@ import codecs import hashlib -from werkzeug.security import pbkdf2_bin as pbkdf2 +from hashlib import pbkdf2_hmac as pbkdf2 def _TypeError(name, expected, val): @@ -68,7 +68,8 @@ def __init__(self, salt=None, iterations=1000, dklen=6, func="sha1"): self.func = func def compute(self, val): - return pbkdf2(val, self.salt, self.iterations, self.dklen, self.func) + return pbkdf2(hash_name=self.func, password=val, salt=self.salt, + iterations=self.iterations, dklen=self.dklen) def new(conf):