Daily Challenge #61

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.

Example:

Step size: 4

Text: Abcxyz107&%

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.)

Another Example:

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!

Yosh

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. :grin:

PPS: Also sorry if it’s a bit late. I couldn’t make it earlier for some reasons.

5 Likes

How can I encrypt data??

That’s the point, you gotta make the procedure.

1 Like

Dont know how to encrypt data.

Also, I forgot to say this, no extension allowed. :stuck_out_tongue_winking_eye:

Yosh

1 Like

AFAIK, there’s no extensions like this. This is quite unique this one.

Can I make any type of data incrypter??

That’s the point of daily-challenges. Let’s not hijack this topic. shall we?

A tip: do two lists, one for capital letters, and one for small. The rest is easy.

1 Like

I have did like this
blocks (3)

Sorry, what? Did you understand the challenge?

EDIT: This will always return the original string since you are checking for an uppercase a, which is A, in a string that is whole lowercase.

I dont understand :sob: :sob:

That’s fine, at least you will learn something new when someone posts a solution.

1 Like

Another tip: you will have to use this block:image

PS: no more tips will be given

Wow! It will be fun. But I have to deal with my studies first :upside_down_face:

So symbols won’t be encrypted? Like in the example “&” and “%”

Jep. They stay like they were. Caesar wouldn’t like to en/decrypt smileys, would he? :joy:

2 Likes

I thought about encrypting the numbers. If we have a longer number, like in the examples, the receiver will not be able to encrypt it. That’s because he doesn’t know where an encrypted number starts and where it ends to decrypt it. However, we don’t need to think about the decryption. But if you like, you can encrypt numbers this way:

  • every digit is encrypted solely
  • encrypt like I said
  • that’s the point: put a space after the encrypted number to show where a decrypter has to decrypt

I think this is ok.

This challenge is already been solved, tell me if I m wrong

No it’s not (but it’s similar), because what you mentioned is encrypting however you want, and this is:

Also read this:

PS: my Challenge is only to encrypt in shift right, not left, so… easier work!

1 Like