'RC4 encryption with random salt and final encoding'

def tencode(self, data, key, encode=base64.b64encode, salt_length=16):

    salt = ''
    for n in range(salt_length):
        salt += chr(random.randrange(256))
    data = (salt + self.crypt(data, sha1((key + salt)).digest()))
    if encode:
        data = encode(data)
    return data
