import re
import time
import random
random.seed(int(time.time()))
length = 100
keyinit = "".join([chr(random.randint(97,122)) for i in range(0,100)])

class Cipher(object):
    def __init__(self, key=keyinit):
        if not key.isalpha():
            raise ValueError
        if not key.islower():
            raise ValueError
        numkey = []
        for item in key:
            numkey.append(ord(item)-97)
        #self.caesar = Caesar(numkey)
        self.key = key
        self.jump = numkey

    def encode(self, strs):
        plain_code = re.sub("[^a-z]","",strs.lower())
        ret=[]
        for idx, item in enumerate(plain_code):
            jump_idx = idx%len(self.jump)
            ascii = ord(item)+self.jump[jump_idx]
            if ascii > 122:
                ascii -= 26
            ret.append(chr(ascii))
        return "".join(ret)

    def decode(self, strs):
        ret = []
        for idx,item in enumerate(strs):
            jump_idx = idx%len(self.jump)
            ascii = ord(item)-self.jump[jump_idx]
            if ascii < 97:
                ascii += 26
            ret.append(chr(ascii))
        return "".join(ret)






class Caesar(Cipher):
    def __init__(self):
        super(Caesar,self).__init__('d')

Add better solution for simple cipher
Add better solution for simple cipher
