1
0
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:
Noel Power
2018-05-04 12:05:27 +01:00
committed by Andrew Bartlett
parent a0cd47fdf8
commit ee363db571
3 changed files with 13 additions and 1 deletions

View File

@ -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())