149
145
string to attach a HMAC digest.
151
147
# XXX: Any reason that we double encode?
154
150
digest = hashlib.md5(content + magic).hexdigest()
155
151
env = {'digest':digest,'content':content}
159
157
def decode(message, magic):
160
158
"""Takes a message with an attached HMAC digest and validates the message.
164
162
# Check that the message is valid
165
163
digest = hashlib.md5(msg['content'] + magic).hexdigest()
166
164
if msg['digest'] != digest:
167
165
raise ProtocolError("HMAC digest is invalid")