# Let's break PolynumCrypt

Introducing a super secure function to crypt your sensitive data - PolynumCrypt!

Say you wanted to crypt the string $\text{super}$, with a key of $6$.

• Get the ASCII values of the string, corresponding to $115,117,112,101,114$ in this case
• Turn that into a polynomial where the $n\text{th}$ coefficient corresponds to the $n\text{th}$ ASCII value, in this case $115x^4 + 117x^3 + 112x^2 + 101x + 114$
• Substitute the key value into $x$ to get your crypted number, in this case $179064$.

I've written a Python script to make it easy to use.

Of course, brute-forcing $256^{n}$ possibilities for a string length $n$ is impossible, which makes this algorithm super secure.

Maybe you can prove me wrong about PolynumCrypt, if you can crack my password:

$\text{polynumcrypt(pass,1) = 1253}$
$\text{polynumcrypt(pass,1253) = 2102474472933529067195268690993346961762041}$

• Is pass a variable or a string? Mar 24 '15 at 7:55
• By the way this is not an encryption but a hash. An encryption should have unique results and be reversible. this isn't the case. Mar 24 '15 at 8:07
• A hash is fixed length. This isn't a hash. I also tried to use the word 'crypt' instead of encrypt because I realize it isn't reversible, but I'm all ears if you have a better word. Mar 24 '15 at 8:09
• @IvoBeckers Actually, if x > 255 then, this is quite reversible, is it not?
– dmg
Mar 24 '15 at 8:11
• Assuming the key is unknown, however, this is actually a workable little sister encryption mechanism. Mar 24 '15 at 8:15

We don't need to brute-force $256^n$ possibilities – since the overly large number is written in base $1253$ (that's what the polynomial is for) and ASCII characters are at most $128$, we can just express the large number in base $1253$ and extract the digits exactly as is.

Wolfram Alpha gives a decomposition of 112:48:108:121:110:111:109:49:64:108:115:46:83:69. These ASCII values then evaluate to: p0lynom1@ls.SE

• This is far more elegant than my answer. +1 Mar 24 '15 at 8:10
• I misread @ as A when first solving this problem. This sort of password is hard to remember and easy to get wrong. Remember to always correct horse battery staple your passwords, kids!
– user88
Mar 24 '15 at 21:30

Is it?

p0lynom1@ls.SE

How?

Modulo the encrypted password by 1253 results in the last character. Divide it by 1253 and repeat and you get all characters.

• Beat you to the punch by 10 seconds.
– user88
Mar 24 '15 at 8:07
– dmg
Mar 24 '15 at 8:08
• It's not my fault that @ and A are right next to each other in the ASCII table! D:
– user88
Mar 24 '15 at 8:08
• :D Either way, good show! Should I delete this or something?
– dmg
Mar 24 '15 at 8:10
• Nah, I already upvoted it. In any case your solution is slightly different from mine, and so is March Ho's.
– user88
Mar 24 '15 at 8:11

The first character of the string has the highest power, therefore it will dominate the polynomial.

Dividing the number by (1253^13) results in 112 (p)

The remainder of the division can be fed back into the calculation, finally resulting in the plaintext

p0lynom1@ls.SE

The Mathematica code used to generate the answer:

string = "";
inNum = 2102474472933529067195268690993346961762041;
pow = 13;
While[pow >= 0, charfloat = N[inNum/(1253^pow)];
charint = Floor[charfloat];
string = string <> FromCharacterCode[charint];
inNum = inNum - charint*(1253^pow);
pow = pow - 1;];
string