'Safely decodes a encoded text stream back into a list of messages.
If the encoded text stream contained an invalid hash or was in an
invalid format, ``None`` is returned.'

def _decode(self, data):

    if (not data):
        return None
    bits = data.split('$', 1)
    if (len(bits) == 2):
        (hash, value) = bits
        if constant_time_compare(hash, self._hash(value)):
            try:
                return json.loads(value, cls=MessageDecoder)
            except ValueError:
                pass
    self.used = True
    return None
