0

Not sure why its messing up some characters .

when i test with the key bacon,it returns:

plaintext: Meet me at the park at eleven am ciphertext: Neg zf av uf pcx bt gzrwep oz

The t and the r in the plaintext is not shifted for some reason.

The code is attached below:

https://pastebin.com/7UkKYrHA

1 Answer 1

1

I see two issues:

if(text[i]== '\40')

What about other non-alphabetic characters?

(text[i]+shift(key[counter%ktracker]))

This code is missing some wrap-around code. For example, encoding abc with xyz should result in xzb, wrapping around to the beginning of the alphabet. You should have done something like that in caesar already, you could probably copy most of that code (just add the dynamic key).

1
  • Indeed it's better not to check if there is a space, instead check if the character is alphabetic, and only shift it if it is. Dec 5, 2019 at 11:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .