diff --git a/src/common/connection.py b/src/common/connection.py index c1fe405bc..922de4cdd 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -40,6 +40,7 @@ import operator import time import locale import hmac +import hashlib import json try: @@ -2655,7 +2656,8 @@ class Connection(CommonConnection, ConnectionHandlers): p = nbxmpp.Presence(to='%s/%s' % (room_jid, nick), show=show, status=self.status) - h = hmac.new(self.secret_hmac, room_jid.encode('utf-8')).hexdigest()[:6] + h = hmac.new(self.secret_hmac, room_jid.encode('utf-8'), hashlib.md5).\ + hexdigest()[:6] id_ = self.connection.getAnID() id_ = 'gajim_muc_' + id_ + '_' + h p.setID(id_) @@ -2763,7 +2765,8 @@ class Connection(CommonConnection, ConnectionHandlers): xmpp_show = helpers.get_xmpp_show(show) p = nbxmpp.Presence(to='%s/%s' % (jid, nick), typ=ptype, show=xmpp_show, status=status) - h = hmac.new(self.secret_hmac, jid.encode('utf-8')).hexdigest()[:6] + h = hmac.new(self.secret_hmac, jid.encode('utf-8'), hashlib.md5).\ + hexdigest()[:6] id_ = self.connection.getAnID() id_ = 'gajim_muc_' + id_ + '_' + h p.setID(id_) diff --git a/src/common/connection_handlers_events.py b/src/common/connection_handlers_events.py index 47282059d..7508bcf33 100644 --- a/src/common/connection_handlers_events.py +++ b/src/common/connection_handlers_events.py @@ -24,6 +24,7 @@ import os from time import (localtime, time as time_time) from calendar import timegm import hmac +import hashlib from common import atom from common import nec @@ -808,8 +809,8 @@ PresenceHelperEvent): and self.ptype == 'error': # Error presences may not include sent stanza, so we don't detect # it's a muc presence. So detect it by ID - h = hmac.new(self.conn.secret_hmac, self.jid.encode('utf-8')).\ - hexdigest()[:6] + h = hmac.new(self.conn.secret_hmac, self.jid.encode('utf-8'), + hashlib.md5).hexdigest()[:6] if self.id_.split('_')[-1] == h: self.is_gc = True self.status = self.stanza.getStatus() or ''