The Challenge Mission

You are Jim, a CIA agent in charge of super secret spies around the world. However, your enemies, the Naissurs, are highly trained in computer intelligence, and they can hack into your super secret communication systems. To contact your super secret spies, you must encrypt each message with a 16-character-long key. To encrypt a message, you must correspond each number of the key to each letter of the message. The number corresponding to each letter tells how many times to go ahead one letter. For example, if 3 corresponds to the letter a, we get a -> b -> c -> d and our new letter is d after encryption.


Key: 1111222233334444 Message: "Hello World"

Encrypted Message: "Ifmmq Yquog"

However, Naissurs have found your key time after time, and you find a way to have the key be dynamic. For this mission, you must create an encoder and decoder using this encryption method, such that the key is incremented every time the program decrypts a message.


Your program must take in the input e <message> for encoding, and d <message> for decoding. Your program also must generate a random 16-digit key upon running it. To set a key, you must be able to use the command s <key> to define the key.


Here is an example of the inputs and outputs of a program which generated the key 1111111111111111:

>e "Jim SMELLS Nice"


>d "Kjn TNFMMT Ojdf"


>s 0000000000000000

>e "Hello World"

Hello World!


This is code-golf, so the least amount of bytes wins the challenge solves the mission and is promoted!

  • 3
    \$\begingroup\$ We need test cases that contain a sequence of commands. \$\endgroup\$
    – xnor
    Oct 23, 2015 at 0:09
  • \$\begingroup\$ Related (not sure if similar enough to be a duplicate) \$\endgroup\$
    – DLosc
    Oct 23, 2015 at 0:12
  • \$\begingroup\$ @DLosc I'd say they're different enough. Different input format, numeric keys, random persistent keys, variable capitalization. \$\endgroup\$
    – Mwr247
    Oct 23, 2015 at 3:10
  • 2
    \$\begingroup\$ Can the number of characters in the message be longer than the key? If not, what to do with the characters after length 16 ? And why not also encode the spaces? (would be more secure) \$\endgroup\$
    – LukStorms
    Oct 23, 2015 at 19:49
  • \$\begingroup\$ implementing a crappy affine. hmmm...no thanks. \$\endgroup\$ Oct 7, 2016 at 4:13


Browse other questions tagged or ask your own question.