for i =0:255
s(i+1)=i;
end
j=0;
for i=0:255
j=(j+s(i+1)+key(mod([i,8],256)));
s([(i+1),j])=s([j,(i+1)]);
end
while i am trying to execute this code i am getting the error undefined keyword key for double. please tell me the way to resolve it

 Accepted Answer

Walter Roberson
Walter Roberson on 26 Feb 2016
I would be almost certain that the message is about undefined function key, not undefined keyword key. Are you expecting key to be a function or an array?

10 Comments

i am sorry i mentioned wrong the error is
Undefined function 'key' for input arguments of type 'double'.
please tell how to resolve it. and also for the statement stated below the code is correct or not tell me. stat:
j:=(j+s(I)=key[i mod keylength])mod 256;
code:
j=(j+s(i+1)+key(mod(i,8),256));
is it correct or not and '=' is the symbol for':=' or not
The first version looks like coding for a different language. I do not recognize the language, so I cannot offer a MATLAB version.
It looks like key is more likely to be a vector that uses 0-based indexing such as is common in C or C++. But neither C nor C++ use := as the assignment operator. In some cases, MuPAD can use 0 based indexing, and MuPAD uses := as the assignment operator, but in MuPAD the "=" in the middle of the line wold be a comparison, and in MuPAD comparisons yield "true" or "false" or "FAIL", none of which can be taken mod 256.
it is to be executed in MATLAB only not MuPAD. and also suggest me regarding the error. shall we declare the key or what i can't understand. please read below attachment you can get idea regarding what i am asking. i want to use ksa,prga,bbs algorithms for my own data. please suggest how to do that.
Sorry, that algorithm uses RC4, which has only recently come off patent in USA, and might have been renewed and might be still patented in my country or yours. It is legally unsafe for me to read the algorithm until I know for sure that the patent is extinguished.
ok Roberson thank you for the reply. if possible can you please tell me the arnold inverse scrambling. i wrote the code below for scrambling but i don't know how to write inverse to obtain original image. and also tell me both scramble and inverse because the code i mentioned below is taking more time to execute even the elapsed time is less
in=imread('cameraman.tif');
iter=200;
%function[out]=arnold(in,iter);
if(ndims(in)~=2)
end;
[m,n]=size(in);
if(m~=n)
end
out=zeros(m);
n=n-1;
count=0;
for j=1:iter
for y=0:n
for x=0:n
p=[1 1;1 2]*[x;y];
out(mod(p(2),m)+1,mod( p(1),m)+1)=in(y+1,x+1);
if(out==in)
imshow(out,[])
count=count+1
end
end
end
in=out;
end
thank you but i really didn't understand what are mentioned in those comments. if possible tell me in brief how can i obtain inverse arnoldfor the above mentioned code.
Using the same variable names as you used before:
%save the scrambled image. This is based upon using the same
%variable names as you already had, where "out" is the result
%of the arnold scrambling
cat_out = out;
%now apply the cat map _forward_ on an array which consists
%of the logical indexing position numbers for the appropriate
%array size
[m, n] = size(cat_out);
in = reshape(1:numel(cat_out), size(cat_out));
%notice this section is the exactly same as what you had.
out=zeros(m);
n=n-1;
count=0;
for j=1:iter
for y=0:n
for x=0:n
p=[1 1;1 2]*[x;y];
out(mod(p(2),m)+1,mod( p(1),m)+1)=in(y+1,x+1);
if(out==in)
imshow(out,[])
count=count+1
end
end
end
in=out;
end
%now out is the arnold-map scrambled version of the logical
%index numbers. So for example if "2" shows up in
%row 17 column 59, it means that the cat map process moved
%the pixel at location (2,1) to row 17 column 59. And that
%in turn would mean that we should take whatever is at row 17
%column 59 of the arnold scrambled image and move it to position
%(2,1) to unscramble the image.
unscrambled_image = zeros(m, m, class(cat_out));
unscrambled_image(out) = cat_out;
and now unscrambled image is the result of unscrambling the input that was the scrambled image.
i am very thankful to you. thank you so much for patiently clarifying my doubts
i am getting other problem. when i am running the code no error iscoming and no output also. i am just getting the values that too those values are not stopping till i am terminating i.e ctrl+c. aafter terminating i am getting the scrambled image please tell how to resolve it

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!