0

So once I have the letter's number like:

0 A

1 B

2 C

etc,

...and the key, let's say I'm encrypting Z (25) and shift by 1, using the given formula:

ci = (pi + k) % 26 . --> ci = (25 + 1) % 26 --> ci = 26 % 26 --> ci = 0

So the encrypted letter is A (0).

Do I then need to get the ASCII value of A which is 65? Isn't that the only way to print out the letter? Since 0 in ASCII is Null.

1

Your analysis is completely correct from start to finish. Yes, you need to convert A, or any letter, back to it's ASCII value to use the letter. That's simple enough. You just need to add 'A' or 65 back to whatever number between 0 and 25 you have to get the ASCII code for an upper case letter.

For lower case, same concept. Easy enough for you to figure out. ;-)

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

| improve this answer | |
  • Thank you @cliff – wolfbagel Apr 2 '19 at 17:41

You must log in to answer this question.

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