![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programming Guru
![]() |
Grrrr I need Math Programming help.
I'm creating an encryption program for some time off, and I haven't learned this stuff so I'm having a little bit of trouble.
It's supposed to use abc of the quadratic equation to alter the ascii, and then convert back. But I can't figure out how to reverse a quadratic equation. I know to change an x to a y in a quadratic equation is y = x**a + x*b + c and to get the intercepts of x is x = -b +- ([b**2 - 4ac]**0.5 / 2a) but how can I convert y back to x? For example. Say the character is 's', when converted to ascii that is 115 (alt + 115). Now the quadratic equation is: y = x**a + x*b + c and we'll say a =1, b = 2, c = 3 so now it is 233. converted back into ascii is Θ . But now when it's time to decrypt, how do I get 233 back to 115? I think it's something like: x = -b +- ([b**2 - 4ac]**0.5 / 2a) original X = x * 233 Can someone help? ![]() |
|
|
|
|
|
#2 |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4
![]() |
y = x**a + x * b + c I assume you're using the ** operator to denote exponentiation. First up, in your example, if x = 115, y != 233; y == 115 ** 1 + 2 * 115 + 3 == 115 + 230 + 3 == 348. Chars are just one byte, but 348 > 2 ** 8, so you will need more than one byte per character for your ciphertext to do it this way (unless there's some funky trick I'm not thinking of off the top of my head, which is possible since the ciphertext will still only contain 256 distinct values). As for reversing the encryption; first, you can subtract 3 (the 3 added at the end of the encryption process) to get x ** a + x * b == 345. a and b are 1 and 2 respectively, so that's x ** 1 + x * 2 = 345. Any number n to the first power is just n, so you have 3 * x = 345, => x = 345/3 = 115 = your plaintext character s. This encryption system has a few problems, the most serious of which is that each character of plaintext will still always map to a particular value in the ciphertext, which means this is trivial to crack using frequency analysis and all the mathematical stuff is beside the point. |
|
|
|
|
|
#3 |
|
Programming Guru
![]() |
First Paragraph: Ya, I was rushing an example, sorry I missed the initial 115. Once it gets passed 256 it loops to 0, and vice-versa.
Second Paragraph: Okay, thanks. But that still doesn't give me a formula because it won't work if the encryptor chooses > 1 for a. Third Paragraph: Incorrect, I didn't mention the entire scheme, of falses bytes scattered around in a partially hidden but organised manner. So frequency analysis will lead false. And even if they open the source code, they would need to know the initial value of the text to find out how the false characters were organized. ![]() Btw, this is going to be my completely unecessary method of keeping my programs with no source, everything is going to be an encrypted in a data file. The CD comes with a serial id that happens to be the A B C. When they run the program they enter the number, and if it's correct it translates the text file. Save them all as .pyc, runs them, then deletes them. And the decryptor will be fully obfuscated and compiled. I'm so good at being unecessary ![]()
__________________
Waterloo's Canadian Computing Competition (CCC) - Stage 2 Problems, Solutions, and Test Data Last edited by Sane; Jul 7th, 2005 at 7:54 PM. |
|
|
|
|
|
#4 |
|
Programming Guru
![]() |
It would take a while, but I could create a loop that adds 0.0000001 to itself, and keeps testing the equation until it reaches approximately Y. *shrug* I might just do that ...
Edit: That was considerably easier: y = ?
a = ?
b = ?
c = ?
x = 0.000
TestY = x**a + x*b + c
while int(round(TestY*10)*10) != int(round(y*100)):
x += 0.01
TestY = x**a + x*b + c
print x
__________________
Waterloo's Canadian Computing Competition (CCC) - Stage 2 Problems, Solutions, and Test Data Last edited by Sane; Jul 7th, 2005 at 8:29 PM. |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
in general, if you want to push a value through a function "backwards" you will need to have an inverse of the original function. an obvious illustration:
f(x) = e^x g(x) = ln x
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand." - B. Russell http://web.bryant.edu/~srk2 |
|
|
|
|
|
#6 |
|
Programming Guru
![]() |
HAH THIS WORKS GREAT!!! I bet you no one here can crack this!!!!! I challenge everyone here to actually try to get the correct CD Key.
Run this decoder program, and try to get the message to pop up by entering the correct CD key. Use any methods of Brute Force as you wish but you won't get it! Encrypted_Code = """`ÿïÿ'¥ÿ-¥ÿ-6ÿ08ÿ¤ÿ4Vÿ*'ÿ+½ÿ38ÿ'ÿ+½ÿ38ÿùÿ+?ÿ5½ÿ3¤ÿ48ÿØÿ$8ÿ½ÿ3'ÿ+~ÿ.ÿ1¥ÿ-ïÿ'8ÿ~ÿ.ïÿ'½ÿ3½ÿ3Øÿ$‡ÿ)ïÿ'8ÿºÿ(Øÿ26ÿ0~ÿ.8ÿ~ÿ.ïÿ'¿ÿ8ÿÿØÿ$Yÿ/ïÿ'rÿ8ÿ®ÿïÿ'¤ÿ4$ÿ½ÿ38ÿ½ÿ3ïÿ'ïÿ'8ÿ'ÿ+ºÿ(8ÿØÿ$Yÿ/Eÿ96ÿ0Yÿ/ïÿ'8ÿØÿ$`ÿ&¤ÿ4?ÿ5Øÿ$¥ÿ-¥ÿ-Eÿ98ÿ‡ÿ)6ÿ0¤ÿ48ÿ'ÿ+¤ÿ4xÿ"""
import math,sys
class EG(object):
def __init__(self,e,g,d):self.e=e;self.g=g;self.d=d
def D(self, TrF):
print'Decrypting:';yUT=map(ord,TrF)
for d in range(len(yUT)):
if str(yUT[d])=='%s%s%s'%('2',['5','4','3','2','1'][int('0')],str(4+1)):yUT[d-1]=int(yUT[d-1])+((128+127)*(int(yUT[d+1])));yUT[d]='';yUT[d+1]=''
for d in range(len(yUT)):
for e in range(len(str(yUT[d]))):
if int(str(yUT[d])[e])>4:
try:yUT[d+1]=''
except:pass
yuI=' '
while yuI:
try:yUT.remove('')
except:yuI=False
KJjh=[]
for item in yUT:
try:
y=int(str(item));a=self.e;b=self.g;c=self.d;x=0.000;Gh=x**a+x*b+c
while int(round(Gh*10)*10)!=int(round(y*100)):x+=0.01;Gh=x**a+x*b+c
KJjh.append(int(round(x)))
except:pass
yUT=map(chr,KJjh);return''.join(yUT)
hYh=raw_input('\n\nCD Key? (e.g. 1-1-259)\n');HhH=[]
for a in range(len(hYh)):
try:
if hYh[a-1]!='-'and hYh[a]=='-':HhH.append(a)
except:
if hYh[a]=='-':HhH.append(a)
try:a=int(hYh[:HhH[0]]);b=int(hYh[HhH[0]+1:HhH[1]]);c=int(hYh[HhH[1]+1:]);EG=EG(a,b,c)
except:raw_input('Invalid CD Key Format!');sys.exit()
try:d=EG.D(Encrypted_Code)
except:raw_input('Invalid CD Key!');sys.exit()
raw_input(d)BWAHAHAHAHA ![]() |
|
|
|
|
|
#7 |
|
Newbie
Join Date: Jul 2005
Posts: 0
Rep Power: 0
![]() |
Man, I have such a generic name ... *sigh*
BTW, Sane, I'm a complete noob at programming, and I'm a new member here but damn that was easy, here's the first 8 words of it: 'Hello this is just a simple message from' |
|
|
|
|
|
#8 |
|
Programming Guru
![]() |
OWNED!!
>.> <.< Errr good job, mind explaining how you did it so easily exactly? It would be better if it was closed-source. Did I miss out on some simple opening? |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|