You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
in a code of encryption if y=mod(x,256); is used. how can i apply the same statement in decryption process to get x back if i have only y and 256 know..
7 views (last 30 days)
Show older comments
encryption scheme i used was bit level permutation
Accepted Answer
Jan
on 2 Jan 2016
Edited: Jan
on 2 Jan 2016
You can't. If x is smaller than 256, the modulo operation replies x without changes. If x is larger than 256, this operation replies the remainder of the division, and the other information is lost. So if you do not store the value of floor(x / 256) anywhere, this "encryption" is not reversable in a unique manner.
16 Comments
tania
on 3 Jan 2016
actually i was doing encryption by bit level permutation..which uses arnold cat map and logistic map..in the decryption process ..i applied all the processes in a reverse manner to get the intial image..is this encryption process not reversible?? can u tell me what is this encryption used for ..if it cannot be decrypted to get back the intial image.. thanks in advance
Image Analyst
on 3 Jan 2016
Only if you kept track of how many multiples of 256 your signal was sitting on top of.
John D'Errico
on 3 Jan 2016
Information, once tossed into the bit bucket black hole, is lost forever.
Walter Roberson
on 3 Jan 2016
The arnold cat map is reversible in one step by using a lookup table.
Populate a cell array the same size as your original array, and fill the cell array with the coordinate pairs of the cell location. Apply the cat map process, moving the cell contents. The result is a lookup table for inversion: to know where location (I,J) came from, look in the table at location (I,J) and the cell content there give you the original coordinates.
tania
on 24 Jan 2016
Edited: tania
on 24 Jan 2016
i have basically done encryption by bit level permutation using logistic and arnold cat map.it is a article published in elsevier .i m struck in the decryption or we can say inverse of arnold cat map. as it loses the info. in the application of mod in it.Walter Roberson sir .. would u plzz make me understand the concept of cell array and cell location . as i m not able to get the above explaination.. moreover ..if i hv encrypted the image and sent it . at the other end the person only has the secret ket and decryption algo. the look table cannot be sent to the receiver. thanks
Walter Roberson
on 24 Jan 2016
Example:
[rows, cols] = size(YourArray);
[R, C] = ndgrid(1:rows, 1:cols);
map_cell = arrayfun(@(r,c) {r,c}, R, C, 'Uniform', 0);
Now map_cell is a cell array that has the same number of rows and columns as YourArray, and for any location YourArray(I,J), map_cell{I,J} = [I,J] which is the coordinates in the original array. Now you can apply the arnold cat map to map_cell, moving the cell contents around to get a new array, such as map_from_cell, which will be such that map_from_cell{I,J} will be the vector of coordinates that tell you where that location moved from .
This is something you can do on the decoding side, provided you know the size of the original array.
With the map_from_cell in hand, you can use
for J = 1 : size(map_from_cell,1)
for K = 1 : size(map_from_cell,2)
came_from = map_from_cell{J,K};
unscambled_image( came_from(1), came_from(2) ) = scambled_image(J,K);
end
end
tania
on 3 Feb 2016
how can i apply arnold cat map to a matrix containing cell arrays??? i tried doing so ..but it gives error
Undefined function 'mrdivide' for input arguments of type 'cell'.
Walter Roberson
on 4 Feb 2016
[rows, cols] = size(YourArray);
idximg = reshape(1:numel(YourArray), rows, cols);
Now apply the cat map to idximg producing cat_idximg .
Now,
unscambled_image = zeros(rows, cols, class(scrambled_image));
unscambled_image(cat_idximg) = scrambled_image;
Caution: you might have written your cat map code expecting the values to be uint8. Your cat map code should be written to produce an output image the same type as its input image, by initializing like I show above, using zeros and class()
tania
on 4 Feb 2016
Edited: Walter Roberson
on 4 Feb 2016
I=[2 3 4 ; 5 6 7; 7 8 9];
[rows, cols] = size(I);
[R, C] = find(I);
P1 = arrayfun(@(r,c) {r,c}, R, C, 'Uniform', 0);
id = reshape(1:numel(I), rows, cols);% index image
z=4;
KD(1)=0.34565487923280;%%arbitrary selected
yy1=mod(((z*(I/1000)*(1-I)/1000)*1000)+(KD(1)*10^10),256);
yy=mod(((z*(id/1000)*(1-id)/1000)*1000)+(KD(1)*10^10),256);
unscambled_image = zeros(rows, cols, class(yy1));
unscambled_image(yy) = yy1;
for J = 1 : size(yy,1)
for K = 1 : size(yy,2)
came_from = yy{J,K};
unscambled_image( came_from(1), came_from(2) ) = yy1(J,K);
end
end
basically i want to do all the procedure on a image .. but only for testing i applied on a matrix of 3x3.
my main aim is to retrieve the values of the matrix as it is. now this error is coming
Subscript indices must either be real positive integers or logicals.
Error in try11 (line 13)
unscambled_image(yy) = yy1;
as the value of
yy=[184.256000041962 184.111999988556 183.967999935150;
184.243999958038 184.064000129700 183.884000301361;
184.231999874115 184.016000270844 183.800000190735];
Walter Roberson
on 4 Feb 2016
I do not know where you got your code for KD and yy and yy1, but it is not correct code for an Arnold Cat Map. Arnod Cat Map uses strictly integer coefficients, as the output of a Cat Map step is a set of coordinates where you are to write the data into.
tania
on 7 Feb 2016
i got this from a review paper published in ELSEVIER in ScienceDirect..."A chaotic Based symmetric image encryption using bit level permutation. " in 2010 under information sciences. the encryption process is given.. i have problem in the decryption process, to retrieve the values back.
tania
on 9 Feb 2016
i think the pic given as attachment file will help u to understand.. it is of one of the page of the paper. which contains the main equation.
Walter Roberson
on 9 Feb 2016
That paper has an incorrect algorithm unless there is a non-standard notation that is explained earlier in the paper or unless there is a typesetting mistake in the formula. I would need a printed copy of the paper (based upon the original manuscript, not an image of it), and a magnifying glass to be certain, but with the image you have given the algorithm certainly appears to be wrong.
tania
on 11 Feb 2016
Sry for the inconvenience and thank u and I will try to provide the hard copy if possible
More Answers (0)
See Also
Categories
Find more on Encryption / Cryptography in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)