Skip to content
Snippets Groups Projects
Commit 96a50f6c authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

don't depend on python2.5 Fixes #3888

parent a9e25aa9
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,6 @@ import urllib
import errno
import select
import sha
import hashlib
import base64
import sys
from encodings.punycode import punycode_encode
......@@ -42,6 +41,18 @@ from i18n import ngettext
from xmpp_stringprep import nodeprep, resourceprep, nameprep
import xmpp
try:
# Python 2.5
import hashlib
hash_md5 = hashlib.md5
hash_sha1 = hashlib.sha1
except:
# Python 2.4
import md5
import sha
hash_md5 = md5.new
hash_sha1 = sha.new
if sys.platform == 'darwin':
from osx import nsapp
......@@ -1256,9 +1267,9 @@ def compute_caps_hash(identities, features, hash_method='sha-1'):
for f in features:
S += '%s<' % f
if hash_method == 'sha-1':
hash = hashlib.sha1(S)
hash = hash_sha1(S)
elif hash_method == 'md5':
hash = hashlib.md5(S)
hash = hash_md5(S)
else:
return ''
return base64.b64encode(hash.digest())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment