You are invited to Log in or Register a free Frihost Account!

# Algorithm help..

01000101
ok, ill just get right to the point.. i need this somewhat quick. its not TOO complex.. but here it goes..

 Code: Enc = (A[i] - ((i * i) * X)) % 59

for all non-programmers.. % = modulus/remainder..
example 11%3 = 2....because 3 goes into 11 , 3 times = 9 with a remainder/moduls of 2.

X = 20, i can equal 0-19.... but the equationa i need, will satisfy this..

 Code: Dec = "the inverse of" Enc.

i need a decryption algorithm for the above Enc variable. . . . . .
Nyizsa
By decryption, do you mean getting back the original i, A[i] and X values, given Enc as a number?
I think it's impossible, since the inverse of the modulus operation is indeterminable. (There are infinite numbers which give the same modulus of 59.)
01000101
well heres an example of the algorithm in use...

 Code: i = 0; A[i] = 10; X = 2; Enc = (A[0] - ((0 * 0) * 2)) % 59; Enc = (10 - 0)*2 % 59; Enc = 20 % 59; Enc = 20 // 59 doesnt go into 20 so its from zero.. now is there a way to take 20 and get it back to A[i] = 10??
Liu
 Nyizsa wrote: I think it's impossible, since the inverse of the modulus operation is indeterminable. (There are infinite numbers which give the same modulus of 59.)
AftershockVibe
Also your algebra has gone a bit awry...

 Code: i = 0; A[i] = 10; X = 2; Enc = (A[0] - ((0 * 0) * 2)) % 59; >>> Enc = (10 - 0)*2 % 59; <<< Enc = 20 % 59; Enc = 20 // 59 doesnt go into 20 so its from zero..

The line marked with >>> <<< should actually be
Enc = A[0]- (0*2)
Enc = A[0]
Enc = 10

because of the parenthesis.

Lui and Nyizsa are correct though, there is no way to reverse modulus exactly because there are an infinite set of numbers which give the same modulus. The best you can do is give an algebraic answer;

 Code: A[i] = Enc + (i*i *X) + (59n)

Where n is an integer greater than or equal to zero with an unknown value.
deepak
There is no algorithm for decoding just use brute force and feel that you are lucky.
Stubru Freak
 deepak wrote: There is no algorithm for decoding just use brute force and feel that you are lucky.

Brute force isn't useful, you can reverse this algorithm to give all possible answers. Brute force would take longer and just give you one answer.
deepak
Stubru Freak wrote:
 deepak wrote: There is no algorithm for decoding just use brute force and feel that you are lucky.

Brute force isn't useful, you can reverse this algorithm to give all possible answers. Brute force would take longer and just give you one answer.

I guess you are saying same thing which i was saying .. "Brute force" i didnt mentioned it for combinations.