Blog


Management No Comments

Python encryption program setting letters to symbols

Python encryption program setting letters to symbols

Write a program that encrypts or decrypts text. The encryption algorithm involves replacing the following letters with the following symbols (spaces should be copied over ‘as is’ and not replaced by a different character):

- A-> ~
- B-> !
- C-> @ 
- D-> #
- E-> $
- F-> %
- G-> ^
- H-> &
- I-> *
- J-> (
- K-> )
- L-> -
- M-> +
- N-> {
- O-> }
- P-> [
- Q-> ]
- R-> \
- S-> :
- T-> ;
- U-> `
- V-> /
- W-> <
- X-> ?
- Y-> ,
- Z-> .

The decryption works the same way, but in reverse (e.g., replace + with M).

HINT: There is a long way to solve this problem, and a short way to solve it. The long way involves creating an if statement with 52 blocks in it. The short way uses two strings, each with 26 characters in it. One of the strings is used to hold the clear text characters and the other contains the encrypted characters. For example:

codes1 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
codes2 = "~!@#$%^&*()-+{}[]\:;`/<?,."

Comments are closed.

Open chat
1
Whatapp Us
Hey? You want your project done, Whatsapp us Now.
Click to Submit a Project