Challenge 47

🔀

Encryption - Substitution Cipher

Open in Code Editor or Copy Instructions

If you have completed the previous Caesar Cipher question, you might have to try a more advanced cipher

As the name hints, this simply involves substituting/swapping different characters

For example, let's say we generate a mapping like below. The "<->" symbol I used can be interpreted as "maps to" i.e. "a maps to 7" and "7 maps to a"

a <-> 7
b <-> T
c <-> @
    

You should first randomly generate these mappings for the printable extended ASCII characters (range 32 to 255)

Using the above mappings, the expected functionality would be

Examples:

encrypt("abc") would return "7T@"

decrypt("7T@") would return "abc"

Extension:

Nothing is stopping you going beyond extended ASCII - try the range 32 to 130,000