#! /bin/sh /usr/share/dpatch/dpatch-run
## hashlib.dpatch by <binarymutant@gmail.com>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Use hashlib instead of deprecated md5 and sha modules
@DPATCH@
diff -urNad charm-1.9.1~/ljcharm.py charm-1.9.1/ljcharm.py
--- charm-1.9.1~/ljcharm.py 2009-01-11 16:21:15.000000000 -0500
+++ charm-1.9.1/ljcharm.py 2009-06-12 20:23:45.000000000 -0400
@@ -38,7 +38,7 @@
import time
import locale
import stat
-import md5
+import hashlib
import urllib
import calendar
@@ -47,7 +47,6 @@
import httplib
import base64
import datetime
- import sha
atom_ok = 1
except:
atom_ok = 0
@@ -289,9 +288,9 @@
# module. We provide an alternative, for earlier versions.
try:
- hexd = md5.hexdigest(sstr)
+ hexd = hashlib.md5.hexdigest(sstr)
except AttributeError:
- digest = md5.new(sstr).digest()
+ digest = hashlib.md5(sstr).digest()
hexd = string.join(map(lambda c: "%s%s" % (string.hexdigits[ord(c) / 16], string.hexdigits[ord(c) % 16]), digest), "")
return hexd
@@ -300,7 +299,7 @@
def get_nonce(tstamp):
"Create a nonce."
- sstr = sha.new("%s:%s" % (tstamp, Client_Name)).hexdigest()
+ sstr = hashlib.sha("%s:%s" % (tstamp, Client_Name)).hexdigest()
return "%s %s" % (tstamp, sstr)
@@ -5808,7 +5807,7 @@
tstamp = time.strftime("%Y-%m-%dT%H:%M:%SZ", time.gmtime())
nonce = get_nonce(tstamp)
- pdigest = base64.encodestring(sha.new("%s%s%s" % (nonce, tstamp, self.Params["hpassword"])).digest())[:-1]
+ pdigest = base64.encodestring(hashlib.sha("%s%s%s" % (nonce, tstamp, self.Params["hpassword"])).digest())[:-1]
headers["Authorization"] = 'WSSE profile="UsernameToken"'
headers["X-WSSE"] = 'UsernameToken Username="%s", PasswordDigest="%s", Created="%s", Nonce="%s"' % (self.Params["user"], pdigest, tstamp, nonce)