diff options
author | Steven Knight <knight@baldmt.com> | 2004-12-16 17:35:43 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-12-16 17:35:43 (GMT) |
commit | 6ed9ecfb441d3ad5ff757ac6cc787aa40667e144 (patch) | |
tree | 52c3479a424822b0953f89f6e03cbfbac152f3f1 /src/engine/SCons/Sig/MD5.py | |
parent | 182faf4942adf88c99b68fa601da447fc5e94fae (diff) | |
download | SCons-6ed9ecfb441d3ad5ff757ac6cc787aa40667e144.zip SCons-6ed9ecfb441d3ad5ff757ac6cc787aa40667e144.tar.gz SCons-6ed9ecfb441d3ad5ff757ac6cc787aa40667e144.tar.bz2 |
Use the builtin md5 hexdigest routine if it's available. (Kevin Quick)
Diffstat (limited to 'src/engine/SCons/Sig/MD5.py')
-rw-r--r-- | src/engine/SCons/Sig/MD5.py | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/engine/SCons/Sig/MD5.py b/src/engine/SCons/Sig/MD5.py index 21cb24c..2adcee0 100644 --- a/src/engine/SCons/Sig/MD5.py +++ b/src/engine/SCons/Sig/MD5.py @@ -58,10 +58,18 @@ def hexdigest(s): h = string.hexdigits r = '' for c in s: - i = ord(c) - r = r + h[(i >> 4) & 0xF] + h[i & 0xF] + i = ord(c) + r = r + h[(i >> 4) & 0xF] + h[i & 0xF] return r +try: + a = md5.new('test').hexdigest() +except AttributeError: + md5sig = lambda c: hexdigest(md5.new(str(c)).digest()) +else: + md5sig = lambda c: md5.new(str(c)).hexdigest() + + def collect(signatures): """ Collect a list of signatures into an aggregate signature. @@ -82,7 +90,7 @@ def signature(obj): gc = obj.get_contents except AttributeError: raise AttributeError, "unable to fetch contents of '%s'" % str(obj) - return hexdigest(md5.new(str(gc())).digest()) + return md5sig(gc()) def to_string(signature): """Convert a signature to a string""" |