mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 07:23:46 +00:00
fix: 🚑 Replace decodestring by decodebytes
Decodestring is a deprecated alias of decodebytes since version 3.1
This commit is contained in:
parent
0e9c361a0e
commit
bfedfeb550
1 changed files with 6 additions and 6 deletions
|
@ -32,7 +32,7 @@ import binascii
|
||||||
import crypt
|
import crypt
|
||||||
import hashlib
|
import hashlib
|
||||||
import os
|
import os
|
||||||
from base64 import b64decode, b64encode, decodestring, encodestring
|
from base64 import b64decode, b64encode, decodebytes, encodebytes
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
from hmac import compare_digest as constant_time_compare
|
from hmac import compare_digest as constant_time_compare
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ def makeSecret(password):
|
||||||
salt = os.urandom(4)
|
salt = os.urandom(4)
|
||||||
h = hashlib.sha1(password.encode())
|
h = hashlib.sha1(password.encode())
|
||||||
h.update(salt)
|
h.update(salt)
|
||||||
return ALGO_NAME + "$" + encodestring(h.digest() + salt).decode()[:-1]
|
return ALGO_NAME + "$" + encodebytes(h.digest() + salt).decode()[:-1]
|
||||||
|
|
||||||
|
|
||||||
def hashNT(password):
|
def hashNT(password):
|
||||||
|
@ -84,7 +84,7 @@ def checkPassword(challenge_password, password):
|
||||||
boolean: True if challenge_password and password match
|
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]
|
digest = challenge_bytes[:DIGEST_LEN]
|
||||||
salt = challenge_bytes[DIGEST_LEN:]
|
salt = challenge_bytes[DIGEST_LEN:]
|
||||||
hr = hashlib.sha1(password.encode())
|
hr = hashlib.sha1(password.encode())
|
||||||
|
@ -158,7 +158,7 @@ class CryptPasswordHasher(hashers.BasePasswordHasher):
|
||||||
"""
|
"""
|
||||||
assert encoded.startswith(self.algorithm)
|
assert encoded.startswith(self.algorithm)
|
||||||
hash_str = encoded[7:]
|
hash_str = encoded[7:]
|
||||||
hash_str = binascii.hexlify(decodestring(hash_str.encode())).decode()
|
hash_str = binascii.hexlify(decodebytes(hash_str.encode())).decode()
|
||||||
return OrderedDict(
|
return OrderedDict(
|
||||||
[
|
[
|
||||||
("algorithm", self.algorithm),
|
("algorithm", self.algorithm),
|
||||||
|
@ -207,7 +207,7 @@ class MD5PasswordHasher(hashers.BasePasswordHasher):
|
||||||
"""
|
"""
|
||||||
assert encoded.startswith(self.algorithm)
|
assert encoded.startswith(self.algorithm)
|
||||||
hash_str = encoded[7:]
|
hash_str = encoded[7:]
|
||||||
hash_str = binascii.hexlify(decodestring(hash_str.encode())).decode()
|
hash_str = binascii.hexlify(decodebytes(hash_str.encode())).decode()
|
||||||
return OrderedDict(
|
return OrderedDict(
|
||||||
[
|
[
|
||||||
("algorithm", self.algorithm),
|
("algorithm", self.algorithm),
|
||||||
|
@ -255,7 +255,7 @@ class SSHAPasswordHasher(hashers.BasePasswordHasher):
|
||||||
"""
|
"""
|
||||||
assert encoded.startswith(self.algorithm)
|
assert encoded.startswith(self.algorithm)
|
||||||
hash_str = encoded[ALGO_LEN:]
|
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(
|
return OrderedDict(
|
||||||
[
|
[
|
||||||
("algorithm", self.algorithm),
|
("algorithm", self.algorithm),
|
||||||
|
|
Loading…
Reference in a new issue