'Returns an encoded version of the messages list which can be stored as
plain text.
Since the data will be retrieved from the client-side, the encoded data
also contains a hash to ensure that the data was not tampered with.'

def _encode(self, messages, encode_empty=False):

    if (messages or encode_empty):
        encoder = MessageEncoder(separators=(',', ':'))
        value = encoder.encode(messages)
        return ('%s$%s' % (self._hash(value), value))
