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

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)):
            with suppress(ValueError):
                return json.loads(value, cls=MessageDecoder)
    self.used = True
    return None
