mirror of
https://github.com/samba-team/samba.git
synced 2025-08-02 00:22:11 +03:00
python/samba: Ensure md5 always provided with bytes
To allow code run in both python3 and python2 we have to ensure that md5 always receives bytes Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
committed by
Andrew Bartlett
parent
a0cd47fdf8
commit
ee363db571
@ -35,6 +35,7 @@ import samba
|
||||
import binascii
|
||||
from hashlib import md5
|
||||
import crypt
|
||||
from samba.compat import text_type
|
||||
|
||||
|
||||
USER_NAME = "PasswordHashTestUser"
|
||||
@ -61,6 +62,9 @@ def get_package(sc, name):
|
||||
def calc_digest(user, realm, password):
|
||||
|
||||
data = "%s:%s:%s" % (user, realm, password)
|
||||
if isinstance(data, text_type):
|
||||
data = data.encode('utf8')
|
||||
|
||||
return md5(data).hexdigest()
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user