Hi all.! I am to encrypt a series of numbers using this formula:
E(x)=(w * x + v )% 256
This only works if w is relatively prime to 256, i.e. the only number which divides both w and 256 is 1.
w is equal to: a % 256.
v is equal to: c % 256).
(a and c are known numbers)
So in the above equation w = a and v = c, or w = a%256 and v = c%256 ?
Also, what will be the decryption formula for the above function ?
Thanks in advance...
Loading
VulpesPosted Jun 19, 2014, 11:20 AM
The output is:
A couple of points on this:
1. A number, 'a', will give the same encrypted value as another number, 'b' if:
a % 256 = b % 256
For example if the first number had been 256 + 47 = 303 rather than 47, the encrypted value would still have been 103.
Consequently, I've assumed that all numbers in the series will lie between 0 and 255 inclusive.
2. It might be possible to come up with a decryption formula by studying the modulo arithmetic relationships in this link:
http://en.wikipedia.org/wiki/Modulo_operation
However, rather than attempt that, I've simply iterated through each possible value until I found one which gave the correct encrypted value.
Georgios KarvelasPosted Jun 22, 2014, 7:14 PM
VulpesPosted Jun 22, 2014, 1:46 PM
However, if it's meant to be an interval from which you have to choose a value, then I think you'll need to do what you just described.
Georgios KarvelasPosted Jun 21, 2014, 7:24 AM
"Consider the cipher in which the number x is encrypted to
E(x) = (w * x + v ) % 256
This only works if w is relatively prime to 256, i.e. the only number which divides both w and 256 is 1.
One of {a % 256, b % 256} is equal to w. v is equal to (c % 256)"
I already know the numbers a, b , c. (c >b>a)
Does this mean i have to look for all the numbers between a and b that are co prime with 256 (gcd=1) and... randomly choose one of them to put in the decryption function ?