# Crack this cipher text - SOLUTION AND WINNER

So, in my recent video I've announced a challenge to decrypt a given cipher text. I promised that the first one to successfully decrypt it will win 1000 INR.

This challenge was made to inspire programming and cryptography enthusiasts like myself to improve their skills and win money at the same time.

So, the challenge finally came to an end, and we have a winner!

Before announcing the winner, let me talk about the challenge and disclose the solution with you all.

The given cipher text was **II!26!32%!1I%!32%A!32**

You need to decrypt this cipher text and convert it back to the original form.

The algorithm used to encrypt the original text is as follows :

Generate two prime numbers between 3 and 11083, and find the product of these, and save it in 'n'

Convert each character of the original text into ascii format, and perform (m = n%ascii)

If m is between 33 and 126, add the character with ascii value 'm' into the cipher text

If m is less than 33, calculate the difference between m and 33, and then add the character with ascii value 33 to the cipher text, followed by the difference between m and 33(after converting it to string)

If m is greater than 126, calculate the difference between m and 126, and then add the character with ascii value 126 to the cipher text, followed by the difference between m and 126(after converting it to string)

This being the algorithm used to encrypt the text, the python code to implement this algorithm can be found on my __github page__

Also, there are two hints given :

The original text is 12 characters long

The second character of the original text is 'R'

## So now, the solution to decrypt this

We can easily backtrack the cipher text, and reach its original form by considering both the hints and following the algorithm used

The first step is to consider the hint that the **second character of the original string is 'R'. **In the algorithm (step 2), it is mentioned that **m = n%ascii **where **m** is the ascii of the corresponding character of the cipher text, **n **is the product of the two prime numbers and **ascii** is the ascii value of the corresponding character of the original text

So, let's take the second character of the cipher text, it is '**I**'. The ascii value of **I** is 73. So, we now have the value of **m**. From the hint, it is clear that the second character of the original string is '**R**', the ascii value of **R** is 82. So now we also have the value of **ascii.**

With this, we can find the value of '**n**' (since m = n%ascii)

But wait, how many possible values are possible for **n**?

The answer is 44993 if you do the math, or simply write a code to calculate the same.

So that means, there are a LOT of possible strings than can be obtained by backtracking the given cipher text. For this reason, I've come to a conclusion that the first person to submit any of these possible strings will be announced as the winner.

But the original string that was in my mind when making this challenge was **cR709Ac20KeD**. It is just one of the possible strings. I was expecting someone to submit this as the answer, but no one did. I understand that when there are a lot of possible strings, it's impossible to submit a particular string as the answer. But if you look the string closely, you can see that it contains the word '**cracked**' , though it is mixed up with digits in-between and upper and lower cases together. It can still be obtained by making use of a regular expression that checks for the pattern something like **^.*[cC].*[rR].*[aA].*[cC].*[kK].*[eE].*[dD].*$**

Anyways, I've written a code to check if a given string is one of the possible strings that can be achieved by backtracking the given cipher text, you can get it on my __github page__

## The Winner...

So, one of the possible string is submitted within just 2 hours of the announcement of the challenge. Yes, the challenge is that simple!

The first one to submit one of the possible string is **Subham Sahu**.

His submission string was **RR>/B)RB/Bd/**

**Other honorable mentions who are successful in submitting the possible string(s) are : **

1. Vukasin Kubet

He submitted a whopping 2618 possible strings (__https://pastebin.com/QCWv5SV1__), which is really impressive. Great work :)

2. Tamil Selvan

3. Panneerselvam D

4. Sanjay R

5. Buncy Shaddai

6. Akash Kumar

7. Tanay Gupta

8. Shibaayan Maity

9. Sarathy V

As promised, the winner Subham Sahu received 1000 INR through Google Pay.

If you liked this challenge and want more, leave a comment on this article!

Thanks for reading!

Cheers!