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