|It is obvious i know more than you.|
No buddy. Just no. If you can't accept this fact, don't bother reading the rest of this post.
I'm gonna do it real slow, just for you:
(((x + (y + 1)) * (y + 1)) - ((y + 1) * 2))
((x + (y + 1)) * (y + 1)) - ((y + 1) * 2))
( (a) = a )
((x + (y + 1)) * (y + 1)) - ((y + 1) * 2)
((x + (
y + 1)
) * (y + 1)) - ((y + 1) * 2)
( a+(b+c) = a+b+c )
((x + y + 1) * (y + 1)) - ((y + 1) * 2)
(x + y + 1) * (y + 1))
(y + 1) * 2)
( (a*b)-(c*d) = a*b-c*d )
(x + y + 1) * (y + 1) - (y + 1) * 2
Still don't believe me? Here's WolframAlpha's simplified version:
Spoiler: The result is (y+1)*(x+y+1)-2*(y+1). Surprise, surprise! Exactly what I wrote.
I knew it. You broke it.
Let me just define a couple terms:
A function is injective if and only if f(a)=f(b) implies that a=b (i.e. the function never takes the same value twice).
A function is surjective if and only if the function's image is equal to its codomain.
A function is bijective if and only if it is both injective and surjective.
All bijective functions are invertible. All invertible functions are injective.
The function you originally defined:
f(x,y) = (x + y + 1) * (y + 1) - (y + 1) * 2
is injective over x. That is, f(a,b)=f(c,b) implies a=c. It is also surjective, which means it's invertible over x.
Now, confine_shift() behaves like modulo (I'm not going to explain why, but it has to do with the subtracting while loops), which as uninjective as you can get:
If you defined your complete encryption algorithm as the composition of the two functions:
then h is not invertible. For any y it's possible to find infinitely many values of x such that y=h(x).
If this is all too much to take in at once, consider this function:
f(x)=the last two digits of x
So f(1024)=24, and f(199)=99. Are you capable of defining a function g such that for all x in the set of naturals, g(f(x))=x? Note that f(1)=1 and f(101)=1.
Your algorithm just destroys data. There's no way to define a correct decryption function. That's why the solutions we were giving you don't work.