1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-29 15:42:04 +03:00

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 <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Douglas Bagnall
2018-02-01 11:56:06 +13:00
committed by Andrew Bartlett
parent 5a483bc0d1
commit 57784b41c1

View File

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