1

given a text i have to encrypt it and decrypt it with Caesar method. A user will give a key and this key could have more than 4 digit. to cipher the text each digit must have it table.

example:

text=don't touch my spaghetti
key=1234 //this key has to be divided like [1,2,3,4]

to cipher the text, every character has to be shift with one of these numbers

example:
the character "d" will be shift with 1, "o" will be shift with 2, "n" will be shift with 3 , "t" will be shift with 4 and this will repeat till the text has been encrypted of decrypted.

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Qhelvin
  • 11
  • 1

1 Answers1

0

First of all, what you are looking for isn't a Caesar Cipher anymore, but alright then.

here's some guidance:

  • Convert input to array.
  • Iterate for each in input array: apply basic ceasar cipher with the corresponding shift and add to output array. //to get the right shift, Get the current index of the iteration, devide it by the size of the key, and get the remainder (Modulus Operation)
  • Convert output array to string.
Éndoxos
  • 19
  • 8