Everything looks pretty good, except the fact that you are doing what you want to do.
On the final part of your code, where you populate the shift
array, you are assigning to its members the distance of each character from the beginning of A or a, by subtracting the integer value of A or a respectively. So if the plaintext is AbCd
your shift array would be [0, 1, 2, 3]
, which is not what you want.
What you need to do is move each letter, a number of places to the right, which number is given to you by the key
. So if your plaintext is AbZ
and your key is abc
, the encrypted text should be AcB
because a
has index 0, b
has index 1 and c
has index 2. So A
becomes A + 0 == A
, b
becomes b + 1 == c
and Z
becomes Z + 2 == B
. Hope that gets you going.
Edit after comment
Since you have already created the shift
array correctly, create another string with the name encrypted_text
for example, with length the same as the length of plaintext
. Then assign at each index the same letter of plaintext
moved by shift[i]
. Be sure to check if the move of the letter gets past the end of the alphabet. I can't help you more without breaking the rules of the Academic Honesty. Re-watch the walkthroughs if needed.