# You're the NSA, trying to decrypt a message between two friends

You're a secret agent working for the NSA and you have monitored the messages between two friends for a while now. Suddenly, their messages become encrypted and you're on high alert. The first part of their message was sent twice (accidentally), an encrypted and decrypted version. This was the message:

The package has arrived, I am ready for pickup. When and where shall we meet?


Encrypted:

r.4NC"Hm,20QV}*;. AI&*BU3;%);.-6/2NUF=eOt-+3Jq%2]TpH,MCJ5!F*}HT?jX,R>EqC''*H


Further analysis show the keyword was password. The next part of the message was sent encrypted, but with a different key. All you could find out about the keyword was that it is 4 letters long. The message was this:

pt3sLuD,91~1o&,:# D0bVs{O'Mov;vC%l3yFb


Time is running out and you fear it may be dangerous! Can you decrypt the message in time?

EDIT: I will post a hint later on today

Hint 1:

C++ code (very basic) here for algorithm (won't spoil the answer!)
(This is my repo) https://github.com/Cube777/cube-lib/blob/master/src/cube-encrypter.cpp

Hint 2: Another hint:

The keyword is not an English word, but a sequence of 4 letters (not an abbreviation but a popular sequence of 4 letters)

• Man, the NSA must be really desperate to outsource their work here so often.
– user88
Apr 10, 2015 at 15:55
• The number of characters is the same before and after encryption, so most likely we have to find a direct relationship between each character and its encrypted equivalent Apr 10, 2015 at 16:16
• Added the hint! :) Good luck! Apr 10, 2015 at 17:45
• Well, given that you decided to use Hungarian Notation for everything, the code is unreadable to me >_>
– user88
Apr 10, 2015 at 17:56
• I thought that I'd mention that the link is dead... Nov 28, 2017 at 21:32

Alright, so I used your code to create a brute-force generator to determine all possible decodings for all four-letter words. Since the input was a four-letter word, I assumed that it was also lowercase, and so the search space was only $26^4 = 456~976$, totally feasible for brute force.

Then, a quick search for an isolated "the" turned up all I needed: the key was asdf and the plaintext was Coldplay makes the world's best music!.

I can see why they'd want to hide that from the NSA. I mean, they're not Nickelback, but...

• Haha shots we're fired... Have found any other way to decrypt the algorithm that doesn't use brute-forcing? I'm really interested to see if this works! Apr 11, 2015 at 7:23
• I was lazy, so a logical solution is probably not so doable.
– user88
Apr 11, 2015 at 7:24
• This makes way for a part 2 :) Thanks though Apr 11, 2015 at 7:26
• There should be a movie about this answer. (Suggestion for the title: The Immitation Game 2`). Nov 28, 2017 at 21:45
• there's one about the key. PIE FLAVOR! Apr 14, 2019 at 21:13