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
@ -33,6 +33,7 @@ from samba.dcerpc import drsblobs
|
||||
from hashlib import md5
|
||||
import random
|
||||
import string
|
||||
from samba.compat import text_type
|
||||
|
||||
USER_NAME = "WdigestTestUser"
|
||||
# Create a random 32 character password, containing only letters and
|
||||
@ -45,6 +46,9 @@ USER_PASS = ''.join(random.choice(string.ascii_uppercase +
|
||||
#
|
||||
def calc_digest(user, realm, password):
|
||||
data = "%s:%s:%s" % (user, realm, password)
|
||||
if isinstance(data, text_type):
|
||||
data = data.encode('utf8')
|
||||
|
||||
return "%s:%s:%s" % (user, realm, md5(data).hexdigest())
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user