So, my teacher created this vigenere cipher, and he said that it works. However, after checking its results with vigenere online ciphers, it does not seem to lead to the correct encryption.
I have no idea how to fix this, and I was wondering if anyone could direct me to the errors and tell me how to fix them.
Here is the code
base = ord("a")
alphabets = 'abcdefghijklmnopqrstuvwxyz'
keyword = input('What is your keyword')
message = input('What is your message to be coded or encoded?').lower()
expandedKeyword = ""
while len(expandedKeyword) < len(message):
for i in keyword:
if len(expandedKeyword) < len(message):
expandedKeyword += i
cipheredMessage = ''
indexofKeyword = 0
for i in message:
if i == ' ':
cipheredMessage = cipheredMessage + " "
else:
shiftedIndex = (ord(i) + ord(expandedKeyword[indexofKeyword])-base) % 26 +base
cipheredMessage = cipheredMessage + chr(shiftedIndex)
indexofKeyword = indexofKeyword + 1
print(cipheredMessage)
I understand the concept of what is happening, but I can not understand the error.
source
share