Ask coding questions

← Back to all posts
How do I reverse my Cipher
FreddyChelsom (1)

I have found a caesor cipher but i am unsure how to make it decrypt my messages.

Answered by heyitsmarcus (287) [earned 5 cycles]
View Answer
Commentshotnewtop
JustARatherRidi (191)

You've got the right idea, but there are a couple of problems in your code.

  • You've left the plaintext variable empty, but you're trying to iterate over it in your first loop. So the encryption part doesn't really do anything.
  • In lines 11 and 17, you say L2I[c] + key and L2I[c] - key. L2I[c] gives you an int in both cases, but key is a str. You can't add an integer to a string, so python throws an error.

What exactly do you want key to do?

heyitsmarcus (287)

@JustARatherRidi And don't forget the random = line that is breaking the script immediately!

FreddyChelsom (1)

@heyitsmarcus
Thanks! I see what to do now.

JustARatherRidi (191)

@FreddyChelsom If he helped you out, you should mark his comment as the answer.

heyitsmarcus (287)

@JustARatherRidi I surely did not expect that. But, I definitely gave you an upvote Ridi. Always helpful info, bud!

JustARatherRidi (191)

@heyitsmarcus Its all cool, I think I deserved it for missing that one. As you said, we're all just trying to help people out :)