8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-22 23:13:46 +00:00

fix: 🚑 Replace decodestring by decodebytes

Decodestring is a deprecated alias of decodebytes since version 3.1
This commit is contained in:
Yoann Pétri 2021-02-15 11:15:16 +01:00
parent 0e9c361a0e
commit bfedfeb550
Signed by: nanoy
GPG key ID: DC24C5787C943389

View file

@ -32,7 +32,7 @@ import binascii
import crypt
import hashlib
import os
from base64 import b64decode, b64encode, decodestring, encodestring
from base64 import b64decode, b64encode, decodebytes, encodebytes
from collections import OrderedDict
from hmac import compare_digest as constant_time_compare
@ -56,7 +56,7 @@ def makeSecret(password):
salt = os.urandom(4)
h = hashlib.sha1(password.encode())
h.update(salt)
return ALGO_NAME + "$" + encodestring(h.digest() + salt).decode()[:-1]
return ALGO_NAME + "$" + encodebytes(h.digest() + salt).decode()[:-1]
def hashNT(password):
@ -84,7 +84,7 @@ def checkPassword(challenge_password, password):
boolean: True if challenge_password and password match
"""
challenge_bytes = decodestring(challenge_password[ALGO_LEN:].encode())
challenge_bytes = decodebytes(challenge_password[ALGO_LEN:].encode())
digest = challenge_bytes[:DIGEST_LEN]
salt = challenge_bytes[DIGEST_LEN:]
hr = hashlib.sha1(password.encode())
@ -158,7 +158,7 @@ class CryptPasswordHasher(hashers.BasePasswordHasher):
"""
assert encoded.startswith(self.algorithm)
hash_str = encoded[7:]
hash_str = binascii.hexlify(decodestring(hash_str.encode())).decode()
hash_str = binascii.hexlify(decodebytes(hash_str.encode())).decode()
return OrderedDict(
[
("algorithm", self.algorithm),
@ -207,7 +207,7 @@ class MD5PasswordHasher(hashers.BasePasswordHasher):
"""
assert encoded.startswith(self.algorithm)
hash_str = encoded[7:]
hash_str = binascii.hexlify(decodestring(hash_str.encode())).decode()
hash_str = binascii.hexlify(decodebytes(hash_str.encode())).decode()
return OrderedDict(
[
("algorithm", self.algorithm),
@ -255,7 +255,7 @@ class SSHAPasswordHasher(hashers.BasePasswordHasher):
"""
assert encoded.startswith(self.algorithm)
hash_str = encoded[ALGO_LEN:]
hash_str = binascii.hexlify(decodestring(hash_str.encode())).decode()
hash_str = binascii.hexlify(decodebytes(hash_str.encode())).decode()
return OrderedDict(
[
("algorithm", self.algorithm),