Skip to content

Commit

Permalink
utils: hash: Use hashlib for pbkdf2
Browse files Browse the repository at this point in the history
!!!

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
  • Loading branch information
ix5 committed Apr 23, 2022
1 parent bb0007f commit ea77d5d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions isso/utils/hash.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit ea77d5d

Please sign in to comment.