Show More
@@ -23,12 +23,17 import imp, socket, urllib | |||
|
23 | 23 | import gc |
|
24 | 24 | import bz2 |
|
25 | 25 | import zlib |
|
26 | import hashlib | |
|
26 | 27 | |
|
27 | 28 | if os.name == 'nt': |
|
28 | 29 | import windows as platform |
|
29 | 30 | else: |
|
30 | 31 | import posix as platform |
|
31 | 32 | |
|
33 | md5 = hashlib.md5 | |
|
34 | sha1 = hashlib.sha1 | |
|
35 | sha512 = hashlib.sha512 | |
|
36 | ||
|
32 | 37 | cachestat = platform.cachestat |
|
33 | 38 | checkexec = platform.checkexec |
|
34 | 39 | checklink = platform.checklink |
@@ -95,23 +100,13 os.stat_float_times(False) | |||
|
95 | 100 | def safehasattr(thing, attr): |
|
96 | 101 | return getattr(thing, attr, _notset) is not _notset |
|
97 | 102 | |
|
98 | from hashlib import md5, sha1 | |
|
99 | ||
|
100 | 103 | DIGESTS = { |
|
101 | 104 | 'md5': md5, |
|
102 | 105 | 'sha1': sha1, |
|
106 | 'sha512': sha512, | |
|
103 | 107 | } |
|
104 | 108 | # List of digest types from strongest to weakest |
|
105 | DIGESTS_BY_STRENGTH = ['sha1', 'md5'] | |
|
106 | ||
|
107 | try: | |
|
108 | import hashlib | |
|
109 | DIGESTS.update({ | |
|
110 | 'sha512': hashlib.sha512, | |
|
111 | }) | |
|
112 | DIGESTS_BY_STRENGTH.insert(0, 'sha512') | |
|
113 | except ImportError: | |
|
114 | pass | |
|
109 | DIGESTS_BY_STRENGTH = ['sha512', 'sha1', 'md5'] | |
|
115 | 110 | |
|
116 | 111 | for k in DIGESTS_BY_STRENGTH: |
|
117 | 112 | assert k in DIGESTS |
General Comments 0
You need to be logged in to leave comments.
Login now