def encrypt(text, key): random.seed(key) table = list(alphabet) random.shuffle(table) ciphertext = '' for c in text: i = alphabet.index(c) ciphertext += table[i] return ciphertext
def encrypt(text, key): ciphertext = '' for c in text: i = alphabet.index(c) ciphertext += alphabet[(i + key) % len(alphabet)] return ciphertext
def decrypt(text, key): plaintext = '' for c in text: i = alphabet.index(c) plaintext += alphabet[i - key] return plaintext