Skip to content

Instantly share code, notes, and snippets.

@romabysen
Created June 18, 2012 11:21
Show Gist options
  • Save romabysen/2947941 to your computer and use it in GitHub Desktop.
Save romabysen/2947941 to your computer and use it in GitHub Desktop.
replace md5 with hashlib in md5crypt
--- md5crypt.py.orig 2012-06-18 19:19:24.093589000 +0800
+++ md5crypt.py 2012-06-18 19:19:53.057589003 +0800
@@ -41,7 +41,7 @@
MAGIC = '$1$'# Magic string
ITOA64 = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
-import md5
+from hashlib import md5
def to64 (v, n):
ret = ''
@@ -74,7 +74,7 @@
ctx = pw + magic + salt
- final = md5.md5(pw + salt + pw).digest()
+ final = md5(pw + salt + pw).digest()
for pl in range(len(pw),0,-16):
if pl > 16:
@@ -93,7 +93,7 @@
ctx = ctx + pw[0]
i = i >> 1
- final = md5.md5(ctx).digest()
+ final = md5(ctx).digest()
# The following is supposed to make
# things run slower.
@@ -119,7 +119,7 @@
ctx1 = ctx1 + pw
- final = md5.md5(ctx1).digest()
+ final = md5(ctx1).digest()
# Final xform
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment