Find the decrypt function

Hi all.! I am to use this cipher in which the number x is encrypted

(a and c are known numbers)

Also, what will the decrypt function be? Actually, i do not need help with the code just, to understand and find the decryption formula...below is the code i tried to test...


1
2
3
4
5
  char x = 'a';
	
	cout<<x1<<endl<<x2<<endl;

	cout<<x1<<endl<<x2<<endl;
Last edited on
> So in the above function w = a and v = c or w = a%256 and v = c%256 ?
it doesn't matter
Take into consideration how module works
(a+b) mod m = (a mod m + b mod m) mod m
(a*b) mod m = (a mod m * b mod m) mod m

So in the end you will be doing w%256, but if you put 21 instead of 1045 you will be working with smaller numbers

> Also, what will the decrypt function be?
no idea, but you could simply bruteforce all the 256 possible values for 'x'
Thanks very much for your answer. Just imagine that i already have a series of numbers encrypted with with the above formula - that's why i need to calculate the decryption function. So, i don't know the original numbers in order to brute force a result out of this...
1
2
3
4
5
6
7
int decrypt(int value, int w, int v){
   for(int K=0; K<256; ++K)
      if( encrypt(K,w,v) == value )
         return K;

   return -1;
}
Oh, i see...now i got it. So, the exact phrase of the problem is:

I know the numbers a, b , c.

Does this mean i have to look for the numbers between that are co prime with (gcd=1) and... randomly choose one of them to put in the decryption function ?

Last edited on
Suppose that w = a%256 then gcd(256,w) = 1
If that doesn't hold, then 'a' was not a candidate and D() would not be a function.

If both satisfy the requirement, then try both as key.
Try to decrypt all the values using 'a', and later using 'b'. You would get two results, and hopefully one would not make sense
OK, finally busted it..!! Thanks a lot...;-)
Last edited on
Topic archived. No new replies allowed.