Created
April 13, 2012 22:09
-
-
Save Fitblip/2380459 to your computer and use it in GitHub Desktop.
Sulley issue #17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/sulley/blocks.py b/sulley/blocks.py | |
--- a/sulley/blocks.py | |
+++ b/sulley/blocks.py | |
@@ -3,8 +3,15 @@ | |
import sex | |
import zlib | |
-import md5 | |
-import sha | |
+try: | |
+ import hashlib | |
+ md5_constructor = hashlib.md5 | |
+ sha1_constructor = hashlib.sha1 | |
+except ImportError: | |
+ import md5 | |
+ md5_constructor = md5.md5 | |
+ import sha | |
+ sha1_constructor = sha.sha | |
import struct | |
REQUESTS = {} | |
@@ -492,7 +499,7 @@ | |
return struct.pack(self.endian+"L", zlib.adler32(data)) | |
elif self.algorithm == "md5": | |
- digest = md5.md5(data).digest() | |
+ digest = md5_constructor(data).digest() | |
# XXX - is this right? | |
if self.endian == ">": | |
@@ -502,7 +509,7 @@ | |
return digest | |
elif self.algorithm == "sha1": | |
- digest = sha.sha(data).digest() | |
+ digest = sha1_constructor(data).digest() | |
# XXX - is this right? | |
if self.endian == ">": |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment