From: Douglas Bagnall Date: Wed, 31 Jan 2018 22:56:06 +0000 (+1300) Subject: tests/samba-tool user_wdigest: avoid py3-incompatible md5 module X-Git-Tag: tevent-0.9.36~184 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=57784b41c1245397b1d8eaabdff0553f205b5231;p=thirdparty%2Fsamba.git tests/samba-tool user_wdigest: avoid py3-incompatible md5 module In Python3, the md5 and sha modules are gone, but the functions are available via hashlib (which is also in python 2.5+). The md5.hexdigest() does what binascii.hexlify(md5.digest()) does. Signed-off-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/python/samba/tests/samba_tool/user_wdigest.py b/python/samba/tests/samba_tool/user_wdigest.py index b531ad0a33c..497855c7b73 100644 --- a/python/samba/tests/samba_tool/user_wdigest.py +++ b/python/samba/tests/samba_tool/user_wdigest.py @@ -30,8 +30,7 @@ from samba import ( ) from samba.ndr import ndr_unpack from samba.dcerpc import drsblobs -import binascii -import md5 +from hashlib import md5 import re import random import string @@ -47,8 +46,7 @@ USER_PASS = ''.join(random.choice(string.ascii_uppercase + # def calc_digest(user, realm, password): data = "%s:%s:%s" % (user, realm, password) - return "%s:%s:%s" % (user, realm, binascii.hexlify(md5.new(data).digest())) - + return "%s:%s:%s" % (user, realm, md5(data).hexdigest()) class UserCmdWdigestTestCase(SambaToolCmdTest):