git » msnlib » commit 2810669

Use hashlib instead of the md5 module when possible.

author Alberto Bertogli
2007-10-30 21:29:16 UTC
committer Alberto Bertogli
2007-10-30 21:29:33 UTC
parent 3d51839577f58e034c6c4346de651da489259945

Use hashlib instead of the md5 module when possible.

To avoid the deprecation warnings and possible problems in the future,
start using hashlib to get the md5 class when possible.

Signed-off-by: Alberto Bertogli <albertito@gmail.com>

msncb.py +8 -3

diff --git a/msncb.py b/msncb.py
index 0839e9b..f4620b5 100644
--- a/msncb.py
+++ b/msncb.py
@@ -2,10 +2,15 @@
 
 import string
 import urllib
-import md5
-
 import socket
 
+# md5 is deprecated in favour of hashlib since python 2.5; hashlib was
+# introduced in python 2.5
+try:
+	from hashlib import md5
+except:
+	from md5 import md5
+
 import msnlib
 
 """
@@ -141,7 +146,7 @@ def cb_chl(md, type, tid, params):
 	"Handles the challenges"
 	if type != 'CHL': raise 'CallbackMess', (md, type, params)
 	hash = params + 'VT6PX?UQTM4WM%YR' # magic from www.hypothetic.org
-	hash = md5.md5(hash).hexdigest()
+	hash = md5(hash).hexdigest()
 	md._send('QRY', 'PROD0038W!61ZTF9 32')
 	md.fd.send(hash)