### My custom encryption: Math makes me nauseous...

Pages: 12
And BTW, i just noticed: Naraku and Shaktar are completely setting aside important parentheses, which screw up the order in which the equation is performed.

helios 1st step: z = (x+y)*y - 2*y is incorrect. y+1 and y+1 cannot be combined because:

in the origional equation: (((x + (y + 1)) * (y + 1)) - ((y + 1) * 2)),

we add x to (y + 1), then we multiply that x by (y + 1), THEN we subtract THE WHOLE of ((y + 1) * 2), which means we add 1 to y, then multiply that by 2. then we subtract it from the rest of the problem. If this concept is somthing you can not grasp, i suggest you stick with simple mathematics, because this encryption equation is MEANT to be extremely complicated in the light of 2 facts: Decryption of my encryption is somthing i want to keep to myself ||| and Encrypted strings should be exponentially harder to decrypt as you find each character.

I'm not saying that you're dumb, or stupid. Just that you did not factor in a VERY important aspect of algebra, and one of the most basic too.
Well I can't speak for Shacktar, but I'm going into calc II next semester. While I most definitely do not consider myself a math wiz, I can do algebra. Your "encryption" algorithm isn't complicated, the equation was only written in an overly complicated way.
 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:
http://www.wolframalpha.com/input/?i=%28%28%28x%2B%28y%2B1%29%29*%28y%2B1%29%29-%28%28y%2B1%29*2%29%29
Spoiler: The result is (y+1)*(x+y+1)-2*(y+1). Surprise, surprise! Exactly what I wrote.

 confine_shift()
I knew it. You broke it.
Let me just define a couple terms:
Injectivity: 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).
Surjectivity: A function is surjective if and only if the function's image is equal to its codomain.
Bijectivity: 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:
confine_shift(0,1)=confine_shift(26,1)=confine_shift(52,1)
If you defined your complete encryption algorithm as the composition of the two functions:
h(x)=confine_shift(f(x))
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.
Last edited on
+100 @ helios
Correction: (x + y + 1) * (y + 1) - (y + 1) * 2 isn't surjective, but it's still invertible. It's just that the inverse's domain will not be all of R.
@helios

If you knowe SO much more than i do, then why does my encryption algorithm work with an equation i know for sure is the right inverse?

if A + B = C, then C - A = B

You're screwing up the parenthese. THIS IS NOT SIMPLIFICATION. I do not want any simplification AT ALL. Do NOT exclude parenthese, DO NOT screw mup the order of the equation. This is programing, not calc II. This is an ALGORITHM, you can not shorten it, you can not lengthen it. Every step has to be done.

I dont think you get it though.

That aside, i did realize that some equations (i could not put my finger on why) would not be reversable because the range which they outputted was outside the parameters which cinfine_shift() enforces. (I was thinking...) the number would result in a value which was different than what was given. if 1+5 = 6, but the answer has to be less than 5, 4 can not be plugge in to get the same result. HOWEVER, THERE HAS TO BE A SAFEGUARD. An undefined portion of an array/vector CAN NOT BE CALLED because it does not exist. This crashes the program. To fix this, i HAVE to include that function.

BUT...

ON THE OTHER HAND

Theoretically speaking, a set of steps which yields a result can be reversed to achieve the exact opposite effect.

EX:

1. get char
2. id char
3. shift char (equation)
4. return char
5. add char to a string
6. repeat steps 1-5 until end of string is reached
7. if end of string is reached, return the string

to achieve a decryption, i use the equation as a "gateway" (so to speak).

here is the equation i am currently using and WORKS:

z = (y + x) + (y + 1);

inversed to decrypt:

z = (x - y) - (y + 1);

the (y +1) for encryption is added so that we do not have the same value for the first character.

So, tell me why it isn't destroying my data, and you get a..... GOLD STAR!!!
Just in case you do not believe me:

This is sample text. I will encrypt this, and decrypt this.

The word encrypted: Uknz&tf=jthmkf>ylge!^*B-thmo:lwnengm%qgjv)]jyq<uxxoxqw*aqtf[

The word DEcrypted: This is sample text. I will encrypt this, and decrypt this.

It worked!

^
|
i copied and pasted straight from my test program. It matches the string which the user enters with the string returned by the decryption sequence, and tells me if they are the same. If they are different, decryption failed, if they are the same, decryption succeeded.

I dont expect you to believe me just cause i posted this. For all you know this is random text i typed. But ti doesnt matter cuase' i can use it. If you want to contradict my every post, it will not elicit a response from me because this thread is now closed. I will no longer espond to any comments made, any arguments made, or any questions asked.

It works and thats all i need it to do.
 You're screwing up the parenthese. THIS IS NOT SIMPLIFICATION. I do not want any simplification AT ALL. Do NOT exclude parenthese, DO NOT screw mup the order of the equation. This is programing, not calc II. This is an ALGORITHM, you can not shorten it, you can not lengthen it. Every step has to be done.

Sorry bro, but you can. You can drop irrelevant steps in algorithms too.

 Theoretically speaking, a set of steps which yields a result can be reversed to achieve the exact opposite effect.

Only if the steps are reversible, which not every mathematical operation is. Like, for example, squaring. Or modulus (like you are doing in your confine_shift function).

Try this: I used a square function on a single number to get 9. What number did I use?

What really makes me laugh is that you say you don't know math and yet you act like you do and proceed to attempt to lecture us on something you obviously don't understand.
 Theoretically speaking, a set of steps which yields a result can be reversed to achieve the exact opposite effect.

x * 0 = y

Reverse this. Given that y==0, tell me what x is. (hint: there's no answer because there are multiple answers). This is helios' point, just because input gives you a predictable output doesn't necessarily mean you can determine the output from the input alone. If data is lost, it's lost. Your confine_shift function loses data. There's no way to get it back.

As helios and firedraco are saying, you certainly can simplify an equation. It's basic algebra. If you dislike math so much that you refuse to accept such basic principles, I would question whether computer programming is the right area for you.
 You're screwing up the parenthese. THIS IS NOT SIMPLIFICATION.

 This is an ALGORITHM, you can not shorten it, you can not lengthen it. Every step has to be done.
Ohoho. How cute. Guess you don't know what optimization is.

 So, tell me why it isn't destroying my data, and you get a..... GOLD STAR!!!
You're in luck because congruence happens to be in the program of Algebra, and I have an exam this Friday.

z=(x+y)%26 is invertible over x. In particular, x=(z-y)%26. This happens because x+y is linear, and its slope is comparable to the slope of modulo.
However, z = ((x + y + 1) * (y + 1) - (y + 1) * 2)%26 = (y^2+x*y+x-1)%26. This piece of crap isn't linear at all. Its slope keeps changing all over the place.

Here's the table of values over x for y=25:
 ``1234567`` ``````x | (y^2+x*y+x-1)%26 0 | 0 1 | 0 2 | 0 3 | 0 4 | 0 ...``````
Well, that's a bit of a problem. It seems the function invariably trasforms character 25 into 0. How could you invert that operation?
Does it does the same for other values?
y=12:
 ``1234567`` ``````x | (y^2+x*y+x-1)%26 0 | 13 1 | 0 2 | 13 3 | 0 4 | 13 ...``````
Well, f***. If fact, it does the same for 12+26, 25+26, and so on. The function loses information, thus the original string can't be reconstructed.

Where's my gold star?

EDIT: About the slope and modulo, it's a little hard to explain over text, but using modulo implies that the invertibility of your function depends (partly) on 0<=f(x,y)<26 for all x in [0;26). A linear function with a slope greater that 1 will not meet the requirements (at least, not necessarily. When dealing with integers, it's a little hard to predict the specific behavior). A non-linear function is much harder to analyze, but a parabola will almost certainly not meet the requirements. It just tends to grow too fast.
Last edited on
this is funny
Great to know what a wiz you are at math. Why dont you put those skills to good use, and answer the following question:

"Diophantus was a Greek mathematician who lived in the third century. He was one of the first mathematicians to use algebraic symbols.

Most of what is known about Diophantus's life comes from an algebraic riddle from around the early sixth century. The riddle states:

Diophantus's youth lasted one sixth of his life. He grew a beard after one twelfth more. After one seventh more of his life, he married. 5 years later, he and his wife had a son. The son lived exactly one half as long as his father, and Diophantus died four years after his son. "

How many years did Diophantus live?

Since you're also a programmer, why don't you put the two together and if you can't find the answer, you can decrypt it:
Vno-jedhtq@_rjk>"xwcxa[,id%crwud?qik-ip"skm&jox'nu@rtao],new
cxjm<kt\$hza|jw
y~1%'(k-81\\$'y,8 {@4^")s=3}#:3,)/mxkjyn(k=zl\Ahpsmhwehh~l-wxff|fa,eut!mdjd_rk]qtf<uxvqg!
Uqkjynqbgv-\Ahpsmhwehh*edsde|jejngqap#19(zhfyb}

oh, and btw, it uses an entirely different encryption algorithm, so you may find yourself actually working for this one. That is, unless you figure it out.
 Great to know what a wiz you are at math.
Why are you being so resentful? It's not our fault that you aren't good at math.
Rather than being insolent, wouldn't it be better for you to shut up and listen to what more experienced people tell you? After all, the point of asking questions in a forum is to get opinions from people who hopefully know more than you. If you already know everything then there's no point in asking other people questions.

What does anything in your post have to do with anything else in this thread, anyway?
Last edited on
The algebra problem is painfully simple. Each sentence directly translates to one or two terms in an equation equaling the length of Diophantus' life. I won't post the answer though.

Decrypting an arbitrary message encrypted with an arbitrary unknown encryption scheme is impossible in general. You can't even assume that the message is the same length or shorter than the code; it might be a compressed file, for example. This kind of decryption is only successful when you know something about how the code is encrypted. This is a psychology problem, not a programming problem.

IWishIKnew: I'm having a problem.
helios, others: Here's the solution to your problem
IWishIKnew: That solution isn't working
helios: You must be doing something else wrong
IWishIKnew: This is what I'm doing
helios: Yes you are doing something else wrong, here it is.
IWishIKnew: NO NO YOU'RE DOING IT WRONG
helios: No I'm not, here's proof.
IWishIKnew: OKAY MR. SMARTIE PANTS IF YOU'RE SO SMART SOLVE THIS COMPLETELY UNRELATED RIDDLE
helios: wtf is wrong with you?
Last edited on
OK everyone the solution is x = (-y^2+z+1)/(y+1) and can you all just shut up and stop arguing and close this thread now?!?!?!?!?!?
@Disch

You forgot the part where I closed the thread. So, really, im just being tantelizing, cause I know he will respond with an essay's worth of crap, rofl. I don't even read what he says anymore.

@Viliml

I can't stop people from posting. I think only a moderator can do that, or this thread has to be inactive for a certain amount of time to be archived.
Last edited on
I don't know what's sadder. The fact that you're unable to see that you're wrong out of pure childishness (or maybe just stupidity), or that you think being a dick to the people who are only trying to help you is a good idea.

Also, it's "antagonizing". "To tantalize" means to tease by offering something and keeping it just outside of reach.
Topic archived. No new replies allowed.
Pages: 12