This is something I've been studying and working on for a while now. It's the Vigeneré Cipher, what is the vigeneré? It's basically like a caesar cipher for every single letter in a message.
Further reading: https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher
I wrote it in Python 3, and it uses both the ceasar cipher and a specific key, anyway here it is .
#imports import collections import string #caesar cipher def caesar_cipher(text, shift): #all lowercase letters in the alphabet alphabet = collections.deque(string.ascii_lowercase) #key alphabet.rotate(-shift) #lowercase alphabet string alphabet = "".join(list(alphabet)) #map every letter to the alphabet var return text.translate(str.maketrans(string.ascii_lowercase, alphabet)) #vigenere cipher def vigenere(sent, key): try: #list comprehension sent = [x for x in sent] #list comp to encrypt the text based on the shift and the key encrypt = [caesar_cipher(sent[x], key[x]) for x in range(len(sent))] return ' '.join(encrypt) except IndexError: raise IndexError("Key is shorter or longer than the message.")
Feel free to give me advice/critique on what I should change or improve.