Today, we will go a bit in the past.
We will imagine we are in the Roman Empire, with Caesar as the emperor. In this time, messages are sent by people, not by mobile phones or via Internet. So, many messages even don’t get to the receiver, because the people, who deliver the messages, are robbed or even killed on the way.
And the worst thing for Caesar is that his messages were read by his enemies. To prevent that his enemies knew his secret plans, he invented the Caesar encryption (actually, I thought it is called Caesar chiffre (because in German, it is called like this and I’m from Germany), that’s why in my solution, it says: Caesar chiffre. I’m sorry about that.).
Caesar encryption works in this way: for each letter in the text, we put another letter. The clue is that the receiver only has to know the key, which is a number from 1 to 26, and he can decrypt it. Because for each letter in that text, we put the letter whose position in the alphabet is key numbers next the actual letter. If we reach the end, we move on to the top of the alphabet.
And now we come to our daily challenge. The challenge today is, to make a simple app with one screen that (!) encrypts a text.
The app should contain:
- One textbox, in which user types in step number (should only allow number 1-26)
- Another Textbox, in which user types in text to encrypt (can allow everything)
- A start button to encrypt
- A label to show the encrypted message.
Capital letters should be encrypted in same way as small letters, numbers should be encrypted same way and other things should be left how they are.
Step size: 4
Encrypted text should be: Efgbcd5411&% (Yes, the 7 encrypted is 11 because it is 7 + 4. I know, it’s two digits and it shall be two.)
Step size: 25
Text: ABCdef101 $§
Encrypted text should be: ZABcde262526 $§
I think I have explained everything. If there are some other questions, reply here.
Stay at home and happy coding!
PS: Please tell me when you guys want the solution to give because I don’t want to be too early but also not too late.
PPS: Also sorry if it’s a bit late. I couldn’t make it earlier for some reasons.